Reputation: 3169
I have a DataGrid as rowDetailTemplate. in this grid I'd like to add a button on header. I made the following XAML code
<sdk:DataGridTemplateColumn >
<sdk:DataGridTemplateColumn.Header>
<DataTemplate>
<Button Content="Row" Height="23" HorizontalAlignment="Left" VerticalAlignment="Top" Width="30" />
</DataTemplate>
</sdk:DataGridTemplateColumn.Header>
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="Del"></Button>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
Everything works correctly but the this column header. I am getting System.Windows.DataTemplate
instead of the button. What am i doing wrong?
Upvotes: 0
Views: 1864
Reputation: 3169
Finally i found the way by compiling some answers. the following will add a template column with header-Body containing controls:
<sdk:DataGridTemplateColumn >
<sdk:DataGridTemplateColumn.HeaderStyle>
<Style TargetType="sdk:DataGridColumnHeader">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Button Content="Row" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</sdk:DataGridTemplateColumn.HeaderStyle>
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="Del" ></Button>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
Upvotes: 1
Reputation: 715
Try this below link which will help you Button in DataGrid header
Cheers! Vinod
Upvotes: 0