DataGrid 中的组合框未在 WPF 中显示列表

ComboxBox in DataGrid not showing List in WPF

我有一个 Datagrid,在第一列中我有一个包含费用列表的 ComboxBox Types.User 需要 select 费用类型并在下一列中输入金额 [= =23=] 已将此与 ObservableCollection 绑定,但列表未显示 up.This 是我的 xaml,请参阅我已绑定一个 observablecollection 'lstFeeType',这是 FeeType 的列表,例如 Admission、Practicle等等

<DataGrid Name="FTDataGrid" AutoGenerateColumns="False" CanUserAddRows="False" Grid.Row="5" Grid.ColumnSpan="2" ScrollViewer.VerticalScrollBarVisibility="Visible" Height="120" >

            <DataGrid.Columns>
                <DataGridTemplateColumn Header="Fee Type"  Width="*" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ComboBox ItemsSource="{Binding Path=FeeTypeCollection}" Grid.Row="2" Grid.Column="1"  Name="cmbFeeType" Width="165" Height="25" SelectedValuePath="Id" DisplayMemberPath="Description" SelectedItem="{Binding FeeType}" SelectedValue="{Binding FeeType}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="Amount"  Width="*" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Name="tbFeeAmount" Height="25" Width="140" Text="{Binding Path=Amount}" />
                          </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="+" Width="Auto" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button HorizontalAlignment="Center" VerticalAlignment="Center" Background="#2BB3EE" Foreground="#FFFDFAFA" Width="20" Height="20" Style="{StaticResource GelButton}" Click="AddRow_Click" >+</Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="-" Width="Auto" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button   HorizontalAlignment="Center" VerticalAlignment="Center" Background="#2BB3EE" Foreground="#FFFDFAFA" Width="20" Height="20" Style="{StaticResource GelButton}">-</Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>


            </DataGrid.Columns>
        </DataGrid>

代码:

ObservableCollection<FeeCollection> _lstFee;
    public AddEditFee()
    {
        _lstFee = new ObservableCollection<FeeCollection>() { new FeeCollection() { FeeTypeCollection = FeeTypeCollection() } };
        InitializeComponent();
        FTDataGrid.ItemsSource = _lstFee;
    }
    private ObservableCollection<Dictionary> FeeTypeCollection()
    {

        ObservableCollection<Dictionary> lstFeeType = new ObservableCollection<Dictionary>() { new Dictionary() { Id = 1, Description = "Admission" },new Dictionary() { Id = 1, Description = "Tution" },new Dictionary() { Id = 1, Description = "Annual" }, new Dictionary() { Id = 1, Description = "Practicle" }};
        return lstFeeType;
    }
    private void Cancel_Click(object sender, RoutedEventArgs e)
    {
        this.Close();
    }

    private void AddRow_Click(object sender, RoutedEventArgs e)
    {
        _lstFee.Add(new FeeCollection() { FeeTypeCollection = FeeTypeCollection() });

    }

    private void Save_Click(object sender, RoutedEventArgs e)
    {
        int a =FTDataGrid.Items.Count-1;
        FeeCollection docPresObj = new FeeCollection();
        docPresObj = (FeeCollection)(FTDataGrid.Items[a]);
    }

类:

public class Dictionary
{
    public int Id { get; set; }
    public string Description { get; set; }
}
public class FeeCollection
{
   public Dictionary FeeType { get; set; }
   public double Amount { get; set; }
   public ObservableCollection<Dictionary> FeeTypeCollection { get; set; }
}

我做错了什么,请指导我。

我的猜测是,由于 FTDataGrids ItemSource 设置为 _lstFee,因此无法在 FeeCollection 中找到 lstFeeType(通常应显示为绑定错误)。我会尝试将 "lstFeeType" 作为 属性 放入 FeeCollection class .