Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Scrolling not working in DataGrid for Tablet

$
0
0

Problem : I have an application in WPF which will run on tablet. In normal way scrolling(with finger drag in tablet) works fine in DataGrid but as soon as I applied style on this datagrid scrolling  stops in tablet. Below is xaml 

DataGrid x:Name="dgItem"
                      Margin="5"
                      AlternationCount="2"
                      AutoGenerateColumns="False"
                      IsReadOnly="True"
                      ItemsSource="{Binding ItemList}"
                      Style="{DynamicResource DGStyle}"
                      RowDetailsVisibilityMode="Collapsed"
                      ScrollViewer.PanningDeceleration="1000"
                      ScrollViewer.PanningMode="Both"
                      ScrollViewer.PanningRatio="2"
                      SelectedItem="{Binding stProduct,
                                             Mode=TwoWay,
                                             UpdateSourceTrigger=PropertyChanged}"
                      SelectionMode="Single"
                      Visibility="{Binding DataContext.stProductList,
                                           RelativeSource={RelativeSource FindAncestor,
                                                                          AncestorType={x:Type UserControl}},
                                           Converter={StaticResource ItemToVisibility},
                                           Mode=TwoWay}">


 <Style x:Key="DGStyle" TargetType="{x:Type DataGrid}">
        <Setter Property="Background" Value="#FFF" />
        <Setter Property="AlternationCount" Value="2" />
        <Setter Property="GridLinesVisibility" Value="Vertical" />
        <Setter Property="VerticalGridLinesBrush" Value="{DynamicResource GridLineBrush}" />
        <Setter Property="RowStyle" Value="{DynamicResource RowStyle}" />
        <Setter Property="Margin" Value="5" />
        <Setter Property="IsReadOnly" Value="True" />
        <Setter Property="ScrollViewer.IsEnabled"  Value="True"/>
  </Style>


<Style x:Key="RowStyle" TargetType="{x:Type DataGridRow}">
        <Style.Triggers>
            <Trigger Property="ItemsControl.AlternationIndex" Value="0">
                <Setter Property="Background" Value="Aqua" />
            </Trigger>
            <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                <Setter Property="Background" Value="White" />
            </Trigger>
        </Style.Triggers>
    </Style>


Viewing all articles
Browse latest Browse all 18858

Trending Articles