我有一个带有产品的数据网格,分别是序列号列,其中序列号是 DatagridComboboxColumn。我想填充序列号组合框当产品被选择为基于产品 ID 动态选择时。我的 Xaml 是:
<my:DataGrid Name="dgSales" ItemsSource="{Binding}" SelectionUnit="Cell" AutoGenerateColumns="False" >
<my:DataGrid.Columns>
<my:DataGridTextColumn Header="Product" Visibility="Hidden" Binding="{Binding ProductName}"></my:DataGridTextColumn>
<my:DataGridComboBoxColumn Header="Serial No" Width="135"
SelectedValueBinding="{Binding SerialNo}"
SelectedValuePath="SlRecord_Id"
DisplayMemberPath="SlNum"
>
<my:DataGridComboBoxColumn.ElementStyle>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="ItemsSource" Value="{Binding}" />
</Style>
</my:DataGridComboBoxColumn.ElementStyle>
<my:DataGridComboBoxColumn.EditingElementStyle>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="ItemsSource" Value="{Binding}" />
</Style>
</my:DataGridComboBoxColumn.EditingElementStyle>
</my:DataGridComboBoxColumn>
</my:DataGrid.Columns>
</my:DataGrid>
我的数据对象是:
class clsSalesItems : INotifyPropertyChanged, IDataErrorInfo
{
private string _ProductName;
private string _SerialNo;
private ObservableCollection<ModelNos> _SerialNos;
public string ProductName
{
get { return _ProductName; }
set
{
_ProductName = value;
OnPropertyChanged("ProductName");
}
}
public ObservableCollection<ModelNos> SerialNos
{
get
{
return _SerialNos;
}
set
{
_SerialNos = value;
OnPropertyChanged("SerialNos");
}
}
}
我的 SerialNo 课程是:
public class ModelNos
{
private int _SlRecord_Id;
private string _SlNo;
public int SlRecord_Id
{
get { return _SlRecord_Id; }
set
{
_SlRecord_Id = value;
}
}
public string SlNum
{
get { return _SlNo; }
set
{
_SlNo = value;
}
}
}
现在,我的问题是,当产品动态选择时,我想填充串行NO组合列(每种产品的串行NO都不同)。选择产品时,我如何绑定串行no obbobox?