Here is the code I have :
<ScrollViewer Grid.Row="2" CanContentScroll="True">
<DockPanel>
<TreeView x:Name="tView" DockPanel.Dock="Top" VerticalAlignment="Stretch">
[...]
</TreeView>
<TreeView Name="pluginsView" DockPanel.Dock="Top" VerticalAlignment="Stretch">
[...]
</TreeView>
</DockPanel>
</ScrollViewer>
I HAVE to define 2 TreeViews. There are in the same “area” (in mean same [Row, Column]) so I had to use a Panel. I used a StackPanel but the display was not what I wanted.
I used the ScrollViewer so that I get a common scrollbar for the 2 TreeViews when they don’t vertically fit the space of the “area”.
The problem I have is horizontally. When 1 of my 2 TreeView is too “large”, I got a scrollbar that appears but only for the TreeView that is too large, so when I scroll, only one of my TreeView moves horizontally. What I want is that when I scroll, both of my TreeView move horizontally.
I don’t know if it’s clear enough, I can upload screenshots if it’s not clear !
I tried this code too, but it doesn’t work too :
<ScrollViewer Grid.Row="2" CanContentScroll="True">
<Grid Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TreeView Grid.Row="0" x:Name="tView" DockPanel.Dock="Top" VerticalAlignment="Stretch">
[...]
</TreeView>
<TreeView Grid.Row="1" Name="pluginsView" DockPanel.Dock="Top" VerticalAlignment="Stretch">
[...]
</TreeView>
</DockPanel>
</ScrollViewer>
but I got the EXACT same problem.. 🙁
It sounds like it is using the TreeView’s internal
ScrollViewerto scroll the content, not the outerScrollViewer.Usually this is because the content inside the
ScrollVieweris limited in size in some way, so make sure you aren’t limiting the size of theTreeViewor it’s parent panel in any way. This would include Vertical/Horizonal Aligment being set to Stretch.Here’s an example that works to scroll smoothly in both directions. I was a little surprised that I had to set
HorizontalScrollBarVisibilityin the<ScrollViewer>tag to make the Horizontal ScrollBar show up.