10
votes

What is the easiest way to create ScrollViewer with fixed header (control that always stays at the top ignoring the scroll), but which still scrolls horizontally.

Should I write my own ScrollViewer template with header above ScrollContentPresenter, and move it when horizontal scroll value changes, or maybe it's better to put header inside ScrollViewer and move it vertically? Or maybe there is a lot better way to achieve this...

2

2 Answers

0
votes

I think you can achieve the effect you want by nesting scrollviewers.

        <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="50" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <Border Background="Gray">
                <TextBlock Text="HEader" /> 
            </Border>

            <ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">

            </ScrollViewer>
        </Grid>
    </ScrollViewer>
-3
votes

you can disable the vertical scrollbar in this way:

ScrollViewer.VerticalScrollBarVisibility="Disabled"