1

我是 WPF 的新手。我有两个组合框列的数据网格。我想用员工姓名填充一列,用产品名称填充另一列。注意:员工姓名是从实体框架对象员工中检索的,类似的产品名称是从实体框架对象产品中检索的。

下面是不起作用的代码。我不确定如何设置 Datagrid itemsource,因为每个组合框列都从不同的静态资源获取数据?帮助将不胜感激。

<Window.Resources>
    <CollectionViewSource x:Key="EmployeeLookup" Source="{Binding Path=EmpList}"/>
    <CollectionViewSource x:Key="ProdutsLookup" Source="{Binding Path=ProdList}"/>
</Window.Resources>
<DataGrid AutoGenerateColumns="False" Height="203" HorizontalAlignment="Left"     Margin="22,92,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="416">
        <DataGrid.Columns>
            <DataGridComboBoxColumn Header="Employee"  ItemsSource="{Binding Source=   {StaticResource EmployeeLookup}}" DisplayMemberPath="FirstName"/>
            <DataGridComboBoxColumn Header="Products"  ItemsSource="{Binding Source={StaticResource ProdutsLookup}}" DisplayMemberPath="ProductName"/>

        </DataGrid.Columns>
    </DataGrid>
4

0 回答 0