How to get the contents of a row (Model) by mousing over the row
Environment
Product | RadGridView for WPF |
Description
How to obtain a reference to the underlying GridViewRow data model on mouse over.
Solution
Subscribe to the MouseEnter event of the GridViewRow elements. To do this, you can use the RowLoaded and RowUnloaded events of RadGridView as shown in Examples 1 and 2.
Example 1: Add handlers for RowLoaded and RowUnloaded
Example 2: Add MouseEnter event handler and access the hovered item
private object hoveredRowModel;
private void RadGridView_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
{
if (e.Row is GridViewRow)
{
e.Row.MouseEnter += Row_MouseEnter;
}
}
private void RadGridView_RowUnloaded(object sender, Telerik.Windows.Controls.GridView.RowUnloadedEventArgs e)
{
if (e.Row is GridViewRow)
{
e.Row.MouseEnter -= Row_MouseEnter;
}
}
private void Row_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
{
var row = (GridViewRow)sender;
this.hoveredRowModel = row.Item;
}