我在数据网格的列中有一个列表框。汽车是可观察集合(BuyersCollection)内的项目列表。
<telerik:RadGridView ItemsSource="{Binding BuyersCollection}"
<telerik:GridViewDataColumn Header="Cars">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<telerik:RadListBox ItemsSource="{Binding Cars}"
SelectedItem="{Binding SelectedCar,Mode=TwoWay,Source={StaticResource CarsViewModel}}" DisplayMemberPath="name" SelectionMode="Single">
public Car SelectedCar
{
get
{
return selectedCar;
}
set
{
if (selectedCar != value)
{
selectedCar = value;
NotifyPropertyChanged(nameof(SelectedCar));
}
}
}
检查您的绑定范围是否正确。 SelectedCar上的绑定位于Datatemplate中。这意味着您的买家收藏中的每个“买家”都有一个汽车集合:“汽车”和一个名为“精选汽车”的汽车财产。