The task is to change Visibility
property of element inside DataGridTemplateColumn
when the mouse pointer is over a row (regardless of the column).
<controls:DataGridTemplateColumn>
<controls:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<TextBlock VerticalAlignment="Center"
Margin="12, 0, 0, 0"
Text="Mouse is not over" />
<!-- Visible only if the mouse pointer is over a row -->
<Button VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
Mouse is over
</Button>
</Grid>
</DataTemplate>
</controls:DataGridTemplateColumn.CellTemplate>
</controls:DataGridTemplateColumn>
Is it possible to do this in the UWP, preferably with MVVM? In WPF I would probably use a DataTrigger (but Style
doesn't have Triggers
property) or bind the property IsMouseOver, but none of the elements (DataGrid
, DataGridTemplateColumn
, RowStyle
...) has a such property.
Sure, you could use xaml behavior
EventTriggerBehavior
to change Visibility property of element insideDataGridTemplateColumn
when the mouse pointer is over a row.For example