Column Header With Button taking up full cell
I've got a data grid column and the first column contains a delete button implemented as a Template Column:-
<sf:GridTemplateColumn sf:FocusManagerHelper.WantsKeyInput="True" AllowSorting="False">
<sf:GridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="x"
sf:FocusManagerHelper.FocusedElement="True"
sf:VisualContainer.WantsMouseInput="True"
ClickMode="Press"
Click="DeleteEventGroupSet"
Width="Auto"
MinWidth="20"
ToolTip="Delete Event Group Set"
Tag="{Binding}" />
</DataTemplate>
</sf:GridTemplateColumn.CellTemplate>
</sf:GridTemplateColumn>
This works great and shows nicely on screen:-
I want to make the header into a "Delete All" button. I've therefore added a header template:-
<sf:GridTemplateColumn sf:FocusManagerHelper.WantsKeyInput="True" AllowSorting="False">
<sf:GridTemplateColumn.HeaderTemplate>
<DataTemplate>
<Button Content="x"
sf:FocusManagerHelper.FocusedElement="True"
sf:VisualContainer.WantsMouseInput="True"
ClickMode="Press"
Click="DeleteEventAllGroupSets"
Width="Auto"
MinWidth="20"
ToolTip="Delete All Event Group Sets"/>
</DataTemplate>
</sf:GridTemplateColumn.HeaderTemplate>
<sf:GridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="x"
sf:FocusManagerHelper.FocusedElement="True"
sf:VisualContainer.WantsMouseInput="True"
ClickMode="Press"
Click="DeleteEventGroupSet"
Width="Auto"
MinWidth="20"
ToolTip="Delete Event Group Set"
Tag="{Binding}" />
</DataTemplate>
</sf:GridTemplateColumn.CellTemplate>
</sf:GridTemplateColumn>
Functionally this works fine but the appearance on screen has a white border around the button:-
Additionally the button doesn't resize as the column is resized.
What I'd like is for the header button to take up the whole of the header cell and resize with it dynamically. Exactly the same behaviour as I get from the individual row cells.
Manikanda Akash M
Attachment: SfDataGrid_Net80_2d1a9338.zip
That worked perfectly. Thank you.
Manikanda Akash
- 3 Replies
- 2 Participants
- Marked answer
-
DH Declan Hillier
- Jul 22, 2024 09:12 AM UTC
- Jul 26, 2024 04:54 AM UTC