I want to create a multi-timeline control with the following features:
- Each timeline has a header region which remains static to the left
- The remainder of the each timeline can be scrolled horizontally.
- If the control doesn't fit the available horizontal space, a scrollbar should be displayed under the timeline section, but not the headers.
- If the control doesn't fit the available vertical space, a scrollbar should be displayed along the right which scrolls both the headers and the timelines up and down.
The closest I have gotten to this layout is the following xaml:
<Grid>
<HeaderedContentControl>
<HeaderedContentControl.Template>
<ControlTemplate TargetType="HeaderedContentControl">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ContentPresenter ContentSource="Header" ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}" Content="{TemplateBinding HeaderedContentControl.Header}" />
<ScrollViewer Grid.Column="1" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Content="{TemplateBinding ContentControl.Content}"
/>
</Grid>
</ControlTemplate>
</HeaderedContentControl.Template>
<HeaderedContentControl.Header>
<ItemsControl>
<Button Height="80" Content="Fixed Header 1" />
<Button Height="80" Content="Fixed Header 2" />
</ItemsControl>
</HeaderedContentControl.Header>
<ItemsControl>
<StackPanel Orientation="Horizontal" Height="80">
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
</StackPanel>
<StackPanel Orientation="Horizontal" Height="80">
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
</StackPanel>
</ItemsControl>
</HeaderedContentControl>
</Grid>
This gives me the correct horizontal scrolling, but no vertical scrollbar:
So to get vertical scrolling, I just need to wrap the outer HeaderedContentControl element with a ScrollViewer, right?
<Grid>
<ScrollViewer>
<HeaderedContentControl>
<HeaderedContentControl.Template>
<ControlTemplate TargetType="HeaderedContentControl">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ContentPresenter
ContentSource="Header"
ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}"
Content="{TemplateBinding HeaderedContentControl.Header}" />
<ScrollViewer Grid.Column="1"
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
VerticalScrollBarVisibility="Hidden"
HorizontalScrollBarVisibility="Auto"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Content="{TemplateBinding ContentControl.Content}" />
</Grid>
</ControlTemplate>
</HeaderedContentControl.Template>
<HeaderedContentControl.Header>
<ItemsControl>
<Button Height="80" Content="Fixed Header 1" />
<Button Height="80" Content="Fixed Header 2" />
</ItemsControl>
</HeaderedContentControl.Header>
<ItemsControl>
<StackPanel Orientation="Horizontal" Height="80">
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
</StackPanel>
<StackPanel Orientation="Horizontal" Height="80">
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
<Button Width="100" Content="thing" />
</StackPanel>
</ItemsControl>
</HeaderedContentControl>
</ScrollViewer>
</Grid>
The result:
Well it's almost right, but the horizontal scrollbar under my timelines is getting clipped when I reduce the window height. I want it to stay on top like the previous image so I can always horizontally scroll.
Does anyone know how I can achieve this?


