wpf datagrid does not bubble the scrollwheel event

31 Views Asked by At

The scrollwheel does not work on a DataGrid inside a ScrollViewer, although the vertical scrollbar just works fine. I tested with this setup:

<ScrollViewer>
    <StackPanel HorizontalAlignment="Stretch">
        <TextBox Text="Test the Scrollwheel in the Palette" FontWeight="Bold" />
        <TextBox Text="Row 1" Focusable="True" />
        <TextBox Text="Row 2" Focusable="True" />
        <TextBox Text="Row 3" Focusable="True" />
        <TextBox Text="Row 4" Focusable="True" />
        <TextBox Text="Row 5" Focusable="True" />
        <TextBox Text="Row 6" Focusable="True" />
        <TextBox Text="Row 7" Focusable="True" />
        <TextBox Text="Row 8" Focusable="True" />
        <TextBox Text="Row 9" Focusable="True" />
        <TextBox Text="Row 10" Focusable="True" />
        <DataGrid Name="dgProperties" ItemsSource="{Binding Value}"
                  AutoGenerateColumns="False"
                  ColumnWidth="*"
                  HeadersVisibility="None"
                  VerticalScrollBarVisibility="Auto"
                  >
            <DataGrid.Columns>
                <!-- Left Column -->
                <DataGridTextColumn Binding="{Binding Path=Label}" />
                <!-- Right Column -->
                <DataGridTextColumn Binding="{Binding Path=DisplayValue}" />
            </DataGrid.Columns>
        </DataGrid>
    </StackPanel>
</ScrollViewer>

screenshot of the data window

When the Window is resized small enough, a vertical scrollbar appears to scroll through the 10 TextBoxes and the DataGrid with a dozen rows.

When hoovering over the window content, the scrollwheel works great as long as you are over the TextBoxes, but when hovering the DataGrid, the scrollwheel does not cause scrolling.

This makes me think that the ScrollViewer and StackPanel are not the problem. It must be the DataGrid that takes the Scrollwheel event but does not bubble it to the parent ScrollViewer control.

The Focusable attributes I added for a tabbing test, but this seems to make no difference for scrolling.

Is this normal? Do I need more config in the XAML?

Because of other SO posts on similar problems, I added VerticalScrollBarVisibility, but this didn't improve anything.

0

There are 0 best solutions below