2010-07-27 126 views
0

下面的代码适用于DataGridComboBoxColumn,但ComboBox没有SelectedValueBinding属性。我应该用什么来代替?WPF:与组合框数据绑定

<ComboBox 
    Header="Application" 
    SelectedValueBinding="{Binding ApplicationKey}" 
    SelectedValuePath="ApplicationKey" 
    DisplayMemberPath="ApplicationName" 
    ItemsSource="{Binding Source={x:Static app:ApplicationLookup.GetAllOrNone}}"/> 

回答

1

使用
SelectedValue = {Binding Property}
SelectedItem = {Binding Property}

这些都将有同样的效果
,并得到你想要显示的使用路径现在
DisplayMemberPath = Property

+0

为什么不能在datagrid是那么简单?哦,谢谢你的帮助。 – 2010-07-27 05:47:08