开发者

Binding a wpf combobox to an element

A very basic question : I want to bind a wpf ComboBox to a selected element, so it displays the same value as the TextBox:

    <StackPanel DataContext="{Binding ElementName=comboBox1, Path=SelectedItem}">        
    <TextBox Text="{Binding Path=Id}"></TextBox>
    <ComboBox .... 

When changing the value of combobox1, the id of the selected item shows in the TextBox. How do I bind a second ComboBox to the selected item in the first ComboBox to show the same value?

UPDATE : WPF ComboBox…how to set the .Text property? solved it for me : I needed the possibility开发者_开发技巧 to add items other than known beforehand, so the IsEditable property should have been true.


WPF ComboBox…how to set the .Text property? solved it for me : I needed the possibility to add items other than known beforehand, so the IsEditable property should have been true.


Looks ok to me. Maybe you should post a more complete examole. Do you have Selector.IsSynchronizedWithCurrentItem set on the combobox?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜