I have set a contextmenu on the grid and am changing the state of various items in that menu in response to the selection changing on the grid. All works as expected if i first left click on a row before right clicking on it (in that the context menu is correctly based on the currently selected row), however if i right click on an unselected row, selection doesn't change and as such i don't get a correct context menu.
How do i get the grid to change selection on right click ?
I'm an idiot.. sorry.
I didn't twig that
EventManager.RegisterClassHandler( typeof( DataRecordPresenter ), PreviewMouseRightButtonDownEvent,
new MouseButtonEventHandler( onMouseRightButtonDown ) );
is a global registration ....
silly me :)
thanks!
This is failing, because of this line :
if ( drp != null )
SelectedItems.Records.Add( drp.Record );
Where is this SelectedItems.Records defined? This is a property of the XamDataGrid, but you are using it in a different context. Is it possible to provide a sample project so that we can look into it?
Any Ideas?
The code I have is the following
void DRP_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { DataRecordPresenter drp = sender as DataRecordPresenter;
if ( drp != null ) SelectedItems.Records.Add( drp.Record );
}
This is what is failing.
cheers
Are you trying to pass a record from the first grid to the BringIntoView(...) method of the second one?
Please note that you can only request a record to be brought into view of the same grid that the method is being called for.