Datagrid scrollbar stops working

When I launch the application, the vertical scroll bar works as expected. However, when I add a new line / line, the panel (the control that should move up and down the slider) does not slide. Using the mouse wheel, I can scroll through the list of lines, and I can click the up and down arrows. Thus, the scrollbar works, but not as expected. The control should move up and down, as it does at first, but after adding this new line it is not.

I hope this is clear enough, I searched for many problems to find this peculiar behavior, but was unsuccessful. Here is XAML, in part, as it is now:

<DataGrid x:Name="inventoryDataGrid" AutoGenerateColumns="False" SelectedValuePath="Id" EnableRowVirtualization="True" EnableColumnVirtualization="True" Style="{DynamicResource DataGridDemoStyle}" CanUserSortColumns="True" VerticalAlignment="Top" ItemsSource="{Binding Source={StaticResource claimInventoryViewSource}}" RowEditEnding="dgInv_RowEditEnding" CellEditEnding="dgInv_CellEditEnding" SelectionChanged="dgInv_SelectionChanged" IsSynchronizedWithCurrentItem="True" CanUserAddRows="False" RowHeaderWidth="0" Sorting="DataGrid_Standard_Sorting" MouseDoubleClick="inventoryDataGrid_DoubleClick" CanUserDeleteRows="True" SelectionMode="Single" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" Width="999.5" CommandManager.PreviewCanExecute="Grid_PreviewCanExecute" Grid.Column="0" Grid.Row="1" Margin="0,3,0,0" RowDetailsVisibilityMode="VisibleWhenSelected" Height="227" LostFocus="inventoryDataGrid_LostFocus" Background="#FFFCF2E7" AlternatingRowBackground="#FFF2F2D6" RowBackground="#FF6FC4BF" GotFocus="inventoryDataGrid_GotFocus"> <DataGrid.Resources> <Style x:Key="DataGridCellStyle" TargetType="{x:Type DataGridCell}" > <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="Foreground" Value="White"/> </Trigger> </Style.Triggers> </Style> </DataGrid.Resources> <DataGrid.Columns> 

Thanks!

+2
wpf datagrid scrollbar
source share
1 answer

I was able to solve this problem. The problem was that the code that I implemented a long time ago was in the EndEdit routine (found here: the EndEdit equivalent in WPF ), which somehow caused this erratic behavior in my datagrid scrollbar.

As soon as I deleted this code, my scrollbar worked without problems. Then, of course, I had to explore a way to save data in text fields without using EndEdit, but this is not the topic for this Question.

+1
source share

All Articles