I can't seem to find how to get the parent grid of a cell or row. Is this possible? How?
Why?
I found a decent way to be able to deselect rows while maintaining the ability to shift select a range of rows (can't do that with any of the default modes).
I don't want to hard code the grid name below (myGrid in this case):
Why?
I found a decent way to be able to deselect rows while maintaining the ability to shift select a range of rows (can't do that with any of the default modes).
I don't want to hard code the grid name below (myGrid in this case):
EventManager.RegisterClassHandler(typeof(GridViewCell), MouseDownEvent, new MouseButtonEventHandler(GridViewRowOnMouseRightButtonDown));
void GridViewRowOnMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
if (myGrid.SelectedItems.Count == 1)
{
GridViewCell cell = sender as GridViewCell;
GridViewRow cellRow = cell.ParentRow as GridViewRow;
if (cellRow.IsSelected && cellRow.IsValid)
{
cellRow.IsSelected = false;
e.Handled = true;
}
else
{
return;
}
}
}