<ComboBox Height="23" Margin="52,64,33,0" Name="comboBox1"
IsSynchronizedWithCurrentItem="True"
IsEditable="True"
DisplayMemberPath="Value"
SelectedItem="{Binding Path=Number, Mode=TwoWay}"
/>
public class Number : INotifyPropertyChanged
{
private string value;
public string Value
{
get
{
return value;
}
set
{
this.value = value;
this.PropertyChanged(this, new PropertyChangedEventArgs("Value"));
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged = delegate { };
#endregion
}
comboBox1.ItemsSource = new Number[] { new Number() { Value = "One" },
new Number() { Value = "Two" },
new Number() { Value = "Three" }};
當我編輯組合框文本時,我的綁定數據集未修改。即,目標到源的綁定不會發生。WPF雙向DataBinding - 可編輯組合框到DataView
我試圖綁定到SelectedItem屬性。但是當我設置組合框的Text屬性時,SelectedItem屬性變爲null。 – Subindev 2010-02-04 10:10:09
IsTextSearchEnabled =「True」導致SelctedItem屬性每當我嘗試設置Text屬性時都爲null。 TextSearchEnabled =「False」顯示沒有任何問題,將2種文本綁定到selecteditem propertybinding .. :-) – Subindev 2010-02-04 14:47:08