I have a WPF datagrid inside a UserControl. I have a ComboBox column in the datagrid to load data from database, which is loading well. I again added a ComboBox in the Header with same data (my ultimate goal is, I want to make all the rows Selected with same Header ComboBox selected value).
But the ComboBox in the Header is not getting the DataContext and it is empty.
<DataGridTemplateColumn>
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<ComboBox Grid.Row="1" Width="100" HorizontalAlignment="Center" Name="workGroupHeaderSelect"
ItemsSource="{Binding Path=WorkstationGroups}" SelectedValuePath="ID"
DisplayMemberPath="Name">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox SelectionChanged="WorkGroupSelect_OnSelectionChanged" Grid.Row="1" Width="100" HorizontalAlignment="Center" Name="workGroupSelect"
ItemsSource="{Binding Path=WorkstationGroups}"
SelectedValuePath="ID"
DisplayMemberPath="Name">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
What I am missing here?
My datagrid is inside a User Control.