编辑组合框控件 [英] Editing combobox control
问题描述
大家好,
在我的Xaml页面中,包含1个组合框控件(从districtTable加载Districts),用于插入Taluk和添加按钮控件的文本框控件,
对于Add_Click事件,请将地区ID和Taluk名称插入数据库并显示在数据网格中.它工作正常
在编辑数据网格时遇到问题,在编辑数据网格时获得了区ID和区名称,但无法在组合框中显示(DisplayMemberPath和SelectedValue两者)
有人可以帮我吗
问候,
Sharath
Hai all,
In my Xaml page contains 1 combobox control (loading Districts from districtTable) ,textbox control to insert Taluk and Add button controls ,
For Add_Click event am inserting the District Id and Taluk names into database and displaying in a datagrid.Its working fine
Am facing problem during editing a datagrid, am getting District Id and district name on editing datagrid but not able to show in combobox (both DisplayMemberPath and SelectedValue)
Can any one help me in this please
Regards,
Sharath
推荐答案
我希望您到处都使用双向绑定吗?
I hope you are using twoway binding everywhere ?
<combobox height="40" horizontalalignment="Stretch" verticalalignment="Center">
Name="vormComboBox" Grid.Column="1" Margin="2"
ItemsSource="{Binding ElementName=materiaalComboBox,Path=SelectedItem.Vormen}"
SelectedValuePath="Model.VormId"
ItemTemplate="{StaticResource FotoMateriaalVormTemplate}"
SelectedValue="{Binding Model.FotoVormId,Mode=TwoWay}"
SelectionChanged="vormComboBox_SelectionChanged">
<combobox.itemspanel>
<itemspaneltemplate>
<virtualizingstackpanel />
</itemspaneltemplate>
</combobox.itemspanel>
</combobox>
也许您可以在 DataGrid 内添加 EditItemTemplate .
在指定的列内添加 ComboBox 字段,并将其 DataBinding 属性绑定到您选择的值.根据需要设置 ItemSource,SelectedValuePath,SelectedDisplayMemberPath .
希望对您有所帮助.
May be you can add a EditItemTemplate inside your DataGrid.
Inside the specified column add a ComboBox field and bind its DataBinding property to your seleted value. Set the ItemSource, SelectedValuePath, SelectedDisplayMemberPath as you require it.
Hope it helps.
这篇关于编辑组合框控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!