I have three datagrids: MasterDatagrid, DetailDatagrid, AssocationDatagrid.
Bascially, if i select one row in one of the grid, i press ‘delete’ key to remove a row from that grid.
private void MasterDataGrid_IsMouseCapturedChanged(object sender, DependencyPropertyChangedEventArgs e)
{
??
}
how can i replicate this function in my delete button ? how can i detect where my mouse focus is? and how to detect the right datagrid i am in?
Many thanks
One way to do it:
You can define a focus scope in the xaml on your page or user control using FocusManager.IsFocusScope.
Then on the
OnClickedevent of your button you can get the focused element using FocusManager.GetFocusedElement() method.From there you can get the required item using SelectedItem(s) property and delete it.