2009-07-27 37 views
1

我有一个组合框与国家代码和电话号码(+43 ..,..) 的的ItemsSource是国家的列表,许多属性的对象(代码就是其中之一。) ComboBox所在的DataContext是具有PhoneNumber属性的对象。WPF组合框的更新源

当用户在列表中选择一个国家时,我想使用Country对象的'+43'值更新源PhoneNumber属性(这是一个字符串)。 该列表出现,但源不会更新。怎么做? 当我与这个文本框取代它,一切工作正常:

<TextBox Text="{Binding Path=CountryCode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" /> 

<ComboBox ItemsSource="{x:Static Member=data:Country.AllCountries}" SelectedValuePath="Country.Value.Code" SelectedValue="??" > 

回答

1

OK,我发现我自己的解决方案:

<ComboBox ItemsSource="{x:Static Member=data:Country.AllCountries}" SelectedValuePath="PhonePrefix" SelectedValue="{Binding Path=CountryCode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" > 
+0

我有一个不同的问题,但事实证明,你回答反正帮我,因为在我的情况下,阻塞没有指定“UpdateSourceTrigger = PropertyChanged”... – Shimmy 2010-07-14 19:41:52