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
370
Display fieldchooser by rightclick column headers
posted

Hi,

I would like to display the FieldChooser for my XamTreeGrid by right clicking any column header. How do I do this? I see here there is a ShowFieldCooser command but how do I execute that by right clicking the column headers? I do not care which column was clicked, I always want the user to be able to select from all columns.

Also, how can I change the display order in the field chooser to be same as my XamTreeGrid, not alphabetically, in XAML? Or at least in MVVM ?

BR,

Hilma Maria

Parents
  • 2660
    Verified Answer
    Offline posted
    Hello Hilma Maria,

     

    Thank you for reaching out.

     

    I have been looking into your question and the most straightforward way to achieve this is to create a style, targeting the LabelPresenter type and add an event setter for the PreviewMouseRightButtonDown event:

     

              <igWPF:XamTreeGrid.Resources>
                    <Style TargetType="{x:Type igWPF:LabelPresenter}">
                        <EventSetter Event="PreviewMouseRightButtonDown"
                                     Handler="LB_PreviewMouseRightButtonDown">
                        </EventSetter>
                    </Style>
                </igWPF:XamTreeGrid.Resources>

     

    And in the handler invoke the ShowFieldChooser method on the XamDataTree:

     

    void LB_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
    {
           this.xtg.ShowFieldChooser();
    }

     

    Just for reference and if you require implementing it in a more MVVM-friendly way, I attached a small sample, where the same is achieved with a Behavior of the XamTreeGrid. The solution consists of capturing the PreviewMouseRightButtonDown on the whole control and checking for a LabelPresenter ancestor of the event arguments' OriginalSource. If so, the field chooser is shown. While this solution is a few lines longer than the one above, please, feel free to implement whichever you prefer, depending on your requirements.

     

    Regarding your second question, please refer to this topic about changing the display order of fields in the field chooser.

     

    If you require any further assistance on the matter, please let me know.

     

    Sincerely,
    Bozhidara Pachilova
    Associate Software Developer
Reply Children
No Data