Datagrid滚动条停止工作 [英] Datagrid scroll bar stops working

查看:123
本文介绍了Datagrid滚动条停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行应用程序时,垂直滚动条按预期工作。但是,当我添加一个新行/行时,该栏(应该在滑块上上下移动的控件)不会滑动。用鼠标滚轮可以上下滚动列表,我可以点击上下箭头。所以滚动条的作用,但不如预期。控制应该首先上下滑动,但是在添加新行之后,它不会。

When I run the app, the vertical scroll bar works as expected. However, when I add a new line/row, the bar (control that should go up and down on the slider) doesn't slide. With the mouse wheel I can scroll up and down the list of rows, and I can click on the up and down arrows. So the scroll bar works, but not as expected. The control should slide up and down, like it does at first, but after adding that new line, it does not.

我希望这是很清楚的,我已经搜索了很多问题,发现这个特殊的行为,但是没有成功。这是XAML,部分原因是:

I hope that is clear enough, I've searched many issues to find this peculiar behavior, but was unsuccessful. Here is the 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>

谢谢!

推荐答案

我能够解决这个问题。问题是有一个很久以前我在一个EndEdit例程中实现了代码(在这里找到: EndEdit等效在WPF ),这在我的datagrid滚动条中导致了这种不规则的行为。

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

一旦我删除了这个代码,我的滚动条没有问题。那么当然,我不得不研究一种在文本框中保存数据而不使用EndEdit的方式,但是这个问题的主题是这个问题。

Once I removed this code, my scrollbar worked without problems. Then of course I had to research a way to save the data in text boxes without the use of EndEdit, but that is way off topic for this Question.

这篇关于Datagrid滚动条停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆