我在WPF应用程序中有一个具有以下两个属性的ViewModel:
public Customer Customer { get; set; }
public ObservableCollection<Customer> Customers { get; set; }
在我的视图中我有一个DXGrid。如何将所选项目绑定到客户属性?
答案 0 :(得分:3)
您应该使用SelectedRowsSource
属性。将其绑定到ObservableCollection<Customer>
。您的代码将如下所示:
public ObservableCollection<Customer> SelectedCustomers { get; set; }
public ObservableCollection<Customer> Customers { get; set; }
...
<dxg:GridControl ItemsSource="{Binding Customers}" AutoPopulateColumns="True">
<dxg:GridControl.View>
<dxg:TableView MultiSelectMode="Row" NavigationStyle="Row"
SelectedRowsSource="{Binding SelectedCustomers}" />
</dxg:GridControl.View>
</dxg:GridControl>