Dan Tumaykin
Dan Tumaykin

Reputation: 1253

Enable scrolling when mouse is over GridView

I have the following XAML layout:

<ScrollViewer>
    <Grid>
         <GridView/>
         // several gridviews with other data and other controls
    </Grid>
</ScrollViewer>

The layout is horizontal and scrolling works, when the mouse is outside of GridView. Just at the point in which mouse hovers GridView, the scrolling stops and continues only when mouse leaves GridView. How can I solve the problem?

Upvotes: 1

Views: 915

Answers (2)

Jawahar
Jawahar

Reputation: 4885

The mouse scroll events were eaten by the scroll viewer used inside the Grid View. To avoid this just modify the template of Grid View to something like below (remove the built in scroll viewer from grid view).

         <Style TargetType="GridView" x:Key="GridViewStyle">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <ItemsPresenter Margin="{TemplateBinding Padding}"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

Upvotes: 3

Filip Skakun
Filip Skakun

Reputation: 31724

Thou shalt not put GridViews in a ScrollViewer! That would help. Use a single GridView with groups or a ScrollViewer with a Horizontal-ly Orientation-ed StackPanel of WrapGrids.

Upvotes: 1

Related Questions