Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
465
How to determine what is under the mouse cursor?
posted

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)
{

 

}

Parents
No Data
Reply
  • 28407
    Verified Answer
    posted

    HI,

     Here is a a code snippet 

    void mgrid_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)

    {

     

     

    //throw new NotImplementedException();

     

     

     

     

     

     

     

     

    DependencyObject source = e.OriginalSource as DependencyObject

    ;

     

     

     

    if (source == null) return

    ;

     

     

     

    CellValuePresenter cvp = Infragistics.Windows.Utilities.GetAncestorFromType(source, typeof(CellValuePresenter), true) as CellValuePresenter

    ;

     

     

     

    if (cvp == null) return

    ;

     

     

     

    // get the record cvp.record

    }

Children