The following example demonstrates how to subscribe the MouseEnter and MouseLeave events of each DataRow using EventTriggers in an implicit style. The MouseEnter and MouseLeave event handlers are provided below.
| XAML | Copy Code |
|---|---|
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"> <Grid.Resources> <xcdg:DataGridCollectionViewSource x:Key="cvs_orders" Source="{Binding Source={x:Static Application.Current}, Path=Orders}"/> <Style TargetType="{x:Type xcdg:DataRow}"> <EventSetter Event="MouseEnter" Handler="DataRowMouseEnter"/> <EventSetter Event="MouseLeave" Handler="DataRowMouseLeave"/> </Style> </Grid.Resources> <xcdg:DataGridControl x:Name="OrdersGrid" ItemsSource="{Binding Source={StaticResource cvs_orders}}" View="TableView.LunaNormalColorTheme"/> </Grid> | |
The following code provides the implementation of the MouseEnter and MouseLeave event handlers, which change the background color of a DataRow when the mouse enters and resets it when the mouse leaves.
| MISSING WIDGET TYPE: The "Fallback" Widget Type could not be found. The "Fallback" Widget Type may have been deleted since this Widget was created. |
| MISSING WIDGET TYPE: The "Fallback" Widget Type could not be found. The "Fallback" Widget Type may have been deleted since this Widget was created. |
