a) A ListBox on the left of the screen
b) A TextBox on the right of the screen
c) A ScrollViewer around both
When my mouse is over the TextBox and I use the scrollwheel, the TextBox scrolls. When I scroll to the bottom of the TextBox the ScrollViewer then takes over and scrolls.
When my mouse is over the ListBox and I use the scrollwheel, the ListBox scrolls. When I scroll to the bottom of the ListBox the ScrollViewer does not take over and does not scroll.
The following is a little test window that shows this functionality (my real code is far to long to use as an example)
Expand|Select|Wrap|Line Numbers
- <Window x:Class="Scroll"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Title="Scroll" Height="100" Width="300">
- <Grid>
- <ScrollViewer Name="ScrollViewer1">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <ListBox MaxHeight="200" VerticalAlignment="Top" HorizontalAlignment="Left">
- <ListBoxItem Content="Item 0" FontSize="30" />
- <ListBoxItem Content="Item 1" FontSize="30" />
- <ListBoxItem Content="Item 2" FontSize="30" />
- <ListBoxItem Content="Item 3" FontSize="30" />
- <ListBoxItem Content="Item 4" FontSize="30" />
- <ListBoxItem Content="Item 5" FontSize="30" />
- <ListBoxItem Content="Item 6" FontSize="30" />
- <ListBoxItem Content="Item 7" FontSize="30" />
- </ListBox>
- <TextBox Height="200" Grid.Column="1" TextWrapping="Wrap" FontSize="30"
- VerticalScrollBarVisibility="Auto">This is some text used to fill up the text box with small words. blah blah blah blah blah.</TextBox>
- </Grid>
- </ScrollViewer>
- </Grid>
- </Window>