0
DataGrid 열이 ComboBox 인 경우 DataGrid를 채우는 방법. 다음 코드에서는 열이 채워지지 않고 있지만 comboBoxes에 일부 항목이 포함되어 있습니다.MVVM patern을 기반으로하는 XAML의 데이터 바인딩
샘플 코드 현재 데이터 항목의 속성에 대응 WHCode
<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>
<ComboBox ItemsSource="..." SelectedItem="{Binding WHCode, Mode=TwoWay}" />