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
1180
Get selected header from XamDataGrid when execute context menu on header
posted

Hi Team,

I am currently adding a context menu item on XamDataGrid's header as below. The context Menu contains a few menu items which binded to a command. However, my menu item command needs to use current selected header field. How can I get that via binding?

<

Style TargetType="{x:Type igDP:LabelPresenter}" BasedOn="{x:Static Themes:DataPresenterOffice2k7Blue.LabelPresenter}"

>

<

Setter Property="ContextMenu" Value="{StaticResource headerContextMenu}"/>

</Style

>

<

ContextMenu x:Key="headerContextMenu"

>

<

MenuItem Header="Some Action Menu"

>

<

MenuItem Header="All" Command="{Binding DoActionCommand}"/>

</

ContextMenu>

  • 138253
    Offline posted

    Hello,

     

    I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter. 

  • 138253
    Offline posted

    Hello Xin,

     

    Thank you for your post. I have been looking into it and I can suggest you set the MenuItem’s CommandParameter like this:

     

    CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:LabelPresenter}}}"

     

    And this way the parameter in the Execute method of the Command will be the LabelPresenter. Please let me know if this helps you or you need further assistance on this matter.

     

    Looking forward for your reply.