WPF工具包可编辑组合框
问题描述:
我试图在WPFTOOLKIT数据网格中实现可编辑组合框。用户必须有可能输入新的值。绑定是用MVVM进行的。 除了这个问题之外,一切运作良好:输入新值后,退出组合后,该值将丢失。WPF工具包可编辑组合框
这里是我的XAML代码:
<xcdg:Column FieldName="FlangeType" Title="Flange Type" Width="80" >
<xcdg:Column.CellEditor>
<xcdg:CellEditor>
<xcdg:CellEditor.EditTemplate>
<DataTemplate>
<ComboBox
ItemsSource="{Binding Path= DataContext.FlangeTypes, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
SelectedValue="{xcdg:CellEditorBinding}"
Text="{Binding Path=DataContext.CurrentDrumStandard.FlangeType,UpdateSourceTrigger=LostFocus}"
IsEditable="True"/>
</DataTemplate>
</xcdg:CellEditor.EditTemplate>
</xcdg:CellEditor>
</xcdg:Column.CellEditor>
</xcdg:Column>
预先感谢任何帮助
答
其实我失踪了Text属性的RelativeSource。
更新代码:
<xcdg:Column.CellEditor>
<xcdg:CellEditor>
<xcdg:CellEditor.EditTemplate>
<DataTemplate>
<ComboBox
ItemsSource="{Binding DataContext.FlangeTypes, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
SelectedValue="{xcdg:CellEditorBinding}"
Text="{Binding DataContext.CurrentDrumStandard.FlangeType, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, UpdateSourceTrigger=LostFocus}"
IsEditable="True"/>
</DataTemplate>
</xcdg:CellEditor.EditTemplate>
</xcdg:CellEditor>
</xcdg:Column.CellEditor>
</xcdg:Column>