【问题标题】:C# WPF DataGrid vertical scrollC# WPF DataGrid 垂直滚动
【发布时间】:2011-06-20 18:47:19
【问题描述】:

我在 WPF 数据网格中看到以下行为。 当项目数超过视图区域的高度时,垂直滚动可用。 当我单击视图中的最后一行时,会自动滚动显示最后一行下方的行。

数据网格的第一列是一个复选框。当用户单击最后一行时,我没有收到复选框单击事件。所有其他行中的复选框都可以正常工作。

我想禁用自动滚动,但不知道怎么做。

<Style x:Key="SingleClickEditing"  TargetType="{x:Type toolkit:DataGridCell}">
     <EventSetter Event="CheckBox.Checked" Handler="OnChecked"/>
     <EventSetter Event="CheckBox.Unchecked" Handler="OnChecked"/>
</Style>

【问题讨论】:

  • 没有“CSharp”之类的东西。该语言被命名为“C#”。
  • 发音为“COctothorpe”。 :)

标签: c# wpf xaml datagrid scroll


【解决方案1】:

我在这里找到了解决方案: WPF DataGrid: how do I stop auto scrolling when a cell is clicked?

我改变了DataGrid的样式

 <Style x:Key="SingleClickEditing"  TargetType="{x:Type toolkit:DataGridCell}">
       <EventSetter Event="CheckBox.Checked" Handler="OnChecked"/>
       <EventSetter Event="CheckBox.Unchecked" Handler="OnChecked"/>
       <EventSetter Event="Control.RequestBringIntoView" Handler="DataGrid_Documents_RequestBringIntoView"  />
 </Style>


private void DataGrid_Documents_RequestBringIntoView(object sender,    RequestBringIntoViewEventArgs e)
{
    e.Handled = true;
}

【讨论】:

    【解决方案2】:

    您应该能够设置 Datagrid 上的一个属性,该属性将确定 Vertical、Horizo​​ntal、Both 或 None(关于滚动条)是否可见。

    【讨论】:

      猜你喜欢
      • 2018-12-16
      • 2012-12-05
      • 2012-07-03
      • 1970-01-01
      • 2017-04-13
      • 2021-04-05
      • 2017-11-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多