Actually the issue im facing is slight different than what title says.
I try to sumarize the issue below.
Class PersonnelViewModel
{
public SelectedPersonnelItem PersonnelItemViewModel;
}
Class PersonnelItemViewModel
{
}
Data Context of the View is A whereas the Item source of the data grid is SelectedPersonnelItem which is a B type property in the class A. Now i want to bind the grid column to properties defiend within class A. But its not working as the context of the grid is another class (B). How can i solve this issue ?
XAML
<DataGrid Grid.Row="1"
SelectedItem="{Binding SelectedPersonnelItem}"
Name="PersonnelGrid"
ItemsSource="{Binding PersonnelGridData}"
event:DatagridRowDoubleClickHandler.MethodName="EditRecord"
CanUserAddRows="False">
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsItemChecked, UpdateSourceTrigger=PropertyChanged}"></CheckBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Name/Company"
Binding="{Binding Name}" />
<DataGridTextColumn Header="Qualification"
Binding="{Binding Qualification}" />
<DataGridTextColumn Header="Arrival"
Binding="{Binding ArrivalDate}" />
<DataGridTextColumn Header="Departure"
Binding="{Binding DepartureDate}" />
</DataGrid.Columns>
</DataGrid>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…