0
如何在datagrid列爲ComboBox時填充數據網格。 在下面的代碼中我的列沒有被填充......但組合框包含一些項目。基於MVVM模板的XAML數據綁定
示例代碼。
<Window x:Class="ComboBox_Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<DataGrid ItemsSource="{Binding First}" AutoGenerateColumns="False" Height="200" HorizontalAlignment="Left" Margin="177,60,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="200">
<DataGrid.Columns>
<DataGridTemplateColumn Header="WH Code" Width="70">
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox Height="22" ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}, Path=DataContext.Last}"/>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>` </DataGrid.Columns>
</DataGrid>
</Grid>