Reputation: 2973
I have a column in my DataGrid
that is set like this;
<DataGridTemplateColumn Header="RAMs PDF" Width="*">
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<Button Content="Select RAMs PDF" Click="OnRAMsButtonClick"/>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
This displays a button in each row, but only when I click into the cell that contains the button. If the focus is not inside this cell then the Button
does not appear. Here is what it looks like without clicking into the cell;
However, after clicking into the cell (twice) the Button
appears;
How can I make it so A) the Button
is visible without having to click inside the cell and B) the user only has to click on the cell once for the click event on the Button
to trigger? (instead of the three currently, two to get the button appear, one to perform the click event.
Upvotes: 0
Views: 194
Reputation: 364
Use the CellTemplate instead of CellEditingTemplate
<DataGridTemplateColumn Header="RAMs PDF" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="Select RAMs PDF" Click="OnRAMsButtonClick"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Upvotes: 1