c# - WPF 数据网格组合框列 : how to manage event of selection changed?

标签 c# wpf datagrid combobox

我有一个带有组合框列的数据网格

<DataGridComboBoxColumn x:Name="DataGridComboBoxColumnBracketType" Width="70" Header="Tipo di staffa" SelectedValueBinding="{Binding type, UpdateSourceTrigger=PropertyChanged}">                    
            </DataGridComboBoxColumn>

我想要一个仅当用户将值更改为组合框时才触发的事件。 我该如何解决这个问题?

最佳答案

我在 CodePlex 上找到了解决方案.这是,有一些修改:

<DataGridComboBoxColumn x:Name="Whatever">                    
     <DataGridComboBoxColumn.EditingElementStyle>
          <Style TargetType="{x:Type ComboBox}">
               <EventSetter Event="SelectionChanged" Handler="SomeSelectionChanged" />
          </Style>
     </DataGridComboBoxColumn.EditingElementStyle>           
</DataGridComboBoxColumn>

在代码隐藏中:

private void SomeSelectionChanged(object sender, SelectionChangedEventArgs e)
{
     var comboBox = sender as ComboBox;
     var selectedItem = this.GridName.CurrentItem;

}

关于c# - WPF 数据网格组合框列 : how to manage event of selection changed?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19322271/

相关文章:

c# - C# 中线程的处理(死锁)

c# - 为什么我的数据绑定(bind) TabControl 看起来不像我的非数据绑定(bind) TabControl?

WPF 数据网格 : Blank Row Missing

c# - .NET DataGrid 复制/粘贴

c# - 变量名称长度对 C# 性能有影响吗?

c# - 将通用列表绑定(bind)到转发器 - ASP.NET

c# - 如何在 MVVM 中处理 `ScrollViewer.ScrollChanged` 事件?

c# - 实体数据网格: best way to add computed values?

c# - 你能在 C# 中做 $array ["string"]

wpf - 如何将 Click= 数据绑定(bind)到对象而不是页面上的函数