Hello,
I would like to have a contextmenu on my xamdatagrid, and once I made the selection, I would like to see which Row I had right clicked in first place to show to contextMenu for.
This might sound trivial, but in "object sender" I only get to see the ContextMenu itself and not the slected row. How do I do that please?
<UserControl.Resources><ResourceDictionary><ContextMenu HasDropShadow="True" x:Key="MassDataSetMenu" DataContext="{Binding Source={x:Static vm:ViewModelLocator.CashflowInputViewModelStatic}}"> <Label Content="Fill-Down" MouseLeftButtonDown="MassDataSetClick"/></Label></ContextMenu><Style TargetType="{x:Type igDP:DataRecordCellArea}" ><Setter Property="ContextMenu" Value="{StaticResource MassDataSetMenu}" /></Style></ResourceDictionary></UserControl.Resources>
private void MassDataSetClick(object sender, MouseButtonEventArgs e){
}
Ok I found teh answer myself. i have been a bit confused about how it works. I am pasting the whole code, in case someone else has my problem:
var
source = e.OriginalSource as DependencyObject;
_columnName = cvp.Field.Name;
_row = (
IUnitRowViewModel) rvp.DataRecord.DataItem;
hi matt,
Sorry for coming back to this again. But while it works for selecting the Row, I still don't know how to select the column.
I use your example but use DataRecordPresenter instead of CellValuePresenter.
If I used cellvaluePresenter, it would give me the actual cell instead of Row? Is my assumption correct?
Is there a way to get both? So that I know which row and which cell was selected?
Many Thanks for your help,
Houman
Got a few nice ideas from some of the sites for my site and will see how it looks on mine.
HI,
Here is a a code snippet
void mgrid_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
//throw new NotImplementedException();
;
// get the record cvp.record