【问题标题】:WPF Toolkit editable comboboxWPF 工具包可编辑组合框
【发布时间】:2016-04-18 09:33:43
【问题描述】:

我正在尝试在 WPFTOOLKIT 数据网格中实现一个可编辑的组合框。用户必须能够键入新值。绑定是使用 MVVM 进行的。 除了这个问题,一切都很好:输入新值后,退出组合时该值丢失。

这是我的 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> 

提前感谢您的帮助

【问题讨论】:

    标签: combobox wpftoolkit


    【解决方案1】:

    事实上,我错过了 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-07
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      相关资源
      最近更新 更多