本文介绍了WPF 数据网格组合框列:如何管理选择更改的事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有组合框列的数据网格
I have a datagrid, with a combobox column
<DataGridComboBoxColumn x:Name="DataGridComboBoxColumnBracketType" Width="70" Header="Tipo di staffa" SelectedValueBinding="{Binding type, UpdateSourceTrigger=PropertyChanged}">
</DataGridComboBoxColumn>
我想要一个仅在用户将值更改到组合框时触发的事件.我该如何解决?
I want an event that is fired only when the user changes the value into the combobox.How can I resolve this?
推荐答案
我在 CodePlex 上找到了解决方案.这是,经过一些修改:
I found a solution to this on CodePlex. Here it is, with some modifications:
<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;
}
这篇关于WPF 数据网格组合框列:如何管理选择更改的事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!