views:

253

answers:

2

I have a strange problem with a WPF DataGrid from WPF Toolkit. The scrollbars appear correctly when the number of rows grows, and the scrolling works when you press up or down arrows on the scrollbar.

The problem comes in when I try to drag the scrollbar on the datagrid. My page has a scroll viewer around it. When I click and drag the scrollbar on the grid, it scrolls the page scroller instead. If the scrollbar does not apear on the page, there grid still does not scroll. Is there a workaround for this???

Would really appreciate some help with this issue!

For example, in this case if the page is < 280, it scrolls on drag. But drag scrolling does not work on the grid.

<ScrollViewer ScrollViewer.IsDeferredScrollingEnabled="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
                    <DockPanel>
                        <dg:DataGrid HorizontalScrollBarVisibility="Auto" SelectionMode="Single" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeColumns="False" CanUserSortColumns="False" AutoGenerateColumns="False" RowHeaderWidth="17" ItemsSource="{Binding Path=OrderSearchVm}" IsReadOnly="True" MaxHeight="280" DockPanel.Dock="Top">
                            <dg:DataGrid.Columns>                                   
                                <dg:DataGridTextColumn Width="75" Header="Date" Binding="{Binding Path=OrderDate}" >
                                    <dg:DataGridTextColumn.ElementStyle>
                                        <Style TargetType="{x:Type TextBlock}">
                                            <Setter Property="TextWrapping" Value="Wrap" />
                                        </Style>
                                    </dg:DataGridTextColumn.ElementStyle>
                                </dg:DataGridTextColumn>
                                <dg:DataGridTextColumn Header="Type" Binding="{Binding Path=OrderType}" Width="45"/>
                                <dg:DataGridTextColumn Header="Shipping Name" Binding="{Binding Path=ShipToName}" Width="115">
                                    <dg:DataGridTextColumn.ElementStyle>
                                        <Style TargetType="{x:Type TextBlock}">
                                            <Setter Property="TextWrapping" Value="Wrap" />
                                        </Style>
                                    </dg:DataGridTextColumn.ElementStyle>
                                </dg:DataGridTextColumn>
                                <dg:DataGridTextColumn Header="Shipping Address " Binding="{Binding Path=ShipToAddress}" Width="160">
                                    <dg:DataGridTextColumn.ElementStyle>
                                        <Style TargetType="{x:Type TextBlock}">
                                            <Setter Property="TextWrapping" Value="Wrap" />
                                        </Style>
                                    </dg:DataGridTextColumn.ElementStyle>
                                </dg:DataGridTextColumn>                                   
                                <dg:DataGridTextColumn Header="E-Mail" Binding="{Binding Path=Email}" Width="140">
                                    <dg:DataGridTextColumn.ElementStyle>
                                        <Style TargetType="{x:Type TextBlock}">
                                            <Setter Property="TextWrapping" Value="Wrap" />
                                        </Style>
                                    </dg:DataGridTextColumn.ElementStyle>
                                </dg:DataGridTextColumn>
                            </dg:DataGrid.Columns>
                        </dg:DataGrid>
                    </DockPanel>
    </ScrollViewer>
A: 

Stupid mistake, ScrollViewer.IsDeferredScrollingEnabled="True" is what was causing my problem

Greg R
A: 

Implement follwoing two properties for data grid :

ScrollViewer.IsDeferredScrollingEnabled="True" and ScrollMode="Deferred"

You will be able to scroll properly for data grid

Sachin Hayatnagarkar