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
2165
XamDataGrid field chooser selection
posted

I have a small problem with the field chooser from xam data grid. What i need to do is to change the check / uncheck behavior from double click to one click, which is done here:

<igWPF:LabelPresenter.InputBindings> 
<MouseBinding Command="{x:Static igWPF:FieldChooserCommands.ToggleVisibility}" MouseAction="LeftDoubleClick" /> 
</igWPF:LabelPresenter.InputBindings>

If I change the mouse action from left double click to left click, instead of requiring one less click, it needs one more: Two to select the field, and one to check / uncheck.

Is there anything to do about this, am I doing something wrong?



  • 34510
    Verified Answer
    Offline posted

    Hi dvsegmbh,

    I don't think you are doing anything wrong.  It seems like the LabelPresenter already uses a single left click for something else so that is interferring with your InputBinding.

    In order to deal with this I created a Behavior that attaches to the LabelPresenter in the FieldChooser dialog and when a single click is detected I manually toggle the visibility.

    public class ToggleFieldVisibility : Behavior<LabelPresenter>
    {
        private LabelPresenter Presenter { get { return this.AssociatedObject; } }
    
        protected override void OnAttached()
        {
            Presenter.PreviewMouseLeftButtonDown -= Presenter_PreviewMouseLeftButtonDown;
            Presenter.PreviewMouseLeftButtonDown += Presenter_PreviewMouseLeftButtonDown;
        }
    
        void Presenter_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var fieldChooser = (FieldChooser)Infragistics.Windows.Utilities.GetAncestorFromType(Presenter, typeof(FieldChooser), false);
            fieldChooser.ExecuteCommand(FieldChooserCommands.ToggleVisibility, Presenter.Field);
            e.Handled = true;
        }
    }

    I attached a sample that demonstrates this.

    DataGridFieldChooserToggle.zip