我有一个类,其中包含其他类的列表,我希望能够将该列表用作 WPF 中数据网格的项目源。是否可以让其他类的内部列表出现在下拉列表或组合框中。当用户单击包含集合的列时,我可以只显示另一个子表单,但如果我可以在主网格上查看和编辑集合,它会更优雅。
这是我的课的样子:
private string ChainID = string.Empty;
private string Chain = string.Empty;
private string State = string.Empty;
private string NonMerchID = string.Empty;
private string ReceiptText = string.Empty;
private string Amount = string.Empty;
**private List<string> CT1 = new List<string>(5);**
private string RecyclingFeeFlag = string.Empty;
private string MinPrompt = string.Empty;
private string MaxPrompt = string.Empty;
CT1是我的问题所在。
好的,所以我的 XAML 现在看起来像这样:
<DataGrid AutoGenerateColumns="False" Height="289" HorizontalAlignment="Left" Margin="10,10,0,0" Name="dataGrid1" VerticalAlignment="Top"
Width="481" ItemsSource="{Binding nonMerchData}">
<DataGrid.Columns>
<DataGridTextColumn Header="Chain ID" Binding="{Binding Path=chainID}"></DataGridTextColumn>
<DataGridTextColumn Header="Chain" Binding="{Binding Path=chain}"></DataGridTextColumn>
<DataGridTextColumn Header="State" Binding="{Binding Path=state}"></DataGridTextColumn>
<DataGridTextColumn Header="Non Merch ID" Binding="{Binding Path=nonMerchID}"></DataGridTextColumn>
<DataGridTextColumn Header="Receipt Text" Binding="{Binding Path=receiptText}"></DataGridTextColumn>
<DataGridTextColumn Header="Amount" Binding="{Binding Path=amount}"></DataGridTextColumn>
<DataGridComboBoxColumn Header="CT" x:Name="_CT"></DataGridComboBoxColumn>
<DataGridTextColumn Header="Recycling Fee Flag" Binding="{Binding Path=recyclingFeeFlag}"></DataGridTextColumn>
<DataGridTextColumn Header="Min Prompt" Binding="{Binding Path=minPrompt}"></DataGridTextColumn>
<DataGridTextColumn Header="Max Prompt" Binding="{Binding Path=maxPrompt}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
一切都很好,只是我不知道如何将我的内部列表绑定到组合框列。