This is what I'm trying to do. First I had a XamDataGrid inside a ScrollViewer with scrollbar for the content disabled.
<ScrollViewer x:Name="_scrollViewer" Grid.Column="0" Width="{Binding Path=Content.Content.ScrollViewer.Width}" Height="{Binding Path=Content.Content.ScrollViewer.Height}" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"> <igDP:XamDataGrid x:Name="_grdContent" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> <igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:RecordListControl}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:RecordListControl}"> <ScrollViewer CanContentScroll="False" Focusable="False" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled"> <ItemsPresenter/> </ScrollViewer> </ControlTemplate> </Setter.Value> </Setter> </Style> </igDP:XamDataGrid.Resources> </igDP:XamDataGrid> </ScrollViewer>
I then have 2 external scrollbars that control the content scrolling of the ScrollViewer.
<ScrollBar x:Name="_horizontalscrollBar" Grid.Row="1" Grid.ColumnSpan="2" Orientation="Horizontal" SmallChange="100" LargeChange="100" Minimum="0" Maximum="{Binding ScrollableWidth, ElementName=_scrollViewer}" ViewportSize="{Binding ViewportWidth, ElementName=_scrollViewer}" Value="{Binding HorizontalOffset, ElementName=_scrollViewer, Mode=OneWay}"/>
<ScrollBar x:Name="_verticalScrollBar" Grid.RowSpan="2" Grid.Column="2" Orientation="Vertical" SmallChange="100" LargeChange="100" Minimum="0" Maximum="{Binding ScrollableHeight, ElementName=_scrollViewer}" ViewportSize="{Binding ViewportHeight, ElementName=_scrollViewer}" Value="{Binding VerticalOffset, ElementName=_scrollViewer, Mode=OneWay}"/>
This all work fine with some minor niggles:
1. The SmallChange & LargeChange property in the ScrollBar is not set. Thus clicking the RepeatButton & the arrow buttons of the scrollbar trigger a tiny amount of change. How I set this property properly?
2. Since I have a hierarchical grid, everytime I expand/collapse a record the height of the grid is changed, but the external scrollbar is not aware of this although it's bound to the correct properties (I think). So how do I 'correct' this settings?
Suggestions?
<Style TargetType="{x:Type igDP:RecordListControl}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:RecordListControl}"> <ScrollViewer CanContentScroll="True" Focusable="false" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" ScrollChanged="ScrollViewer_ScrollChanged"> <ItemsPresenter RenderTransform="{TemplateBinding ScrollableElementTransform}" /> </ScrollViewer> </ControlTemplate> </Setter.Value> </Setter> </Style>
I need the ScrollViewer_ScrollChanged so to align other Scrolls with it.
Why it doesn't work when CanContentScroll="False" is set for smoothe scrolling (it cuts off certaing amount of Records at the end)?
Why there is a ViewPort Height change when CanContentScroll = "True"? - this looks like the issue