EventToCommandTrigger / SelectorDoubleClickCommandBehavior issue?

Sep 26, 2012 at 7:31 PM

Thanks for reading this.

Great Framework, it really does work well and has been a great learning tool.

I've been using the TabControlEx workspaces which contain DataGrid controls bound through EF to a database. 

The main problem I'm having is that using SelectorDoubleClickCommandBehavior to handle this event in a datagrid causes the datagrid to become disabled.

In my app I have a command that browses to some URL present in a particular column of the currently selected row.   The command itself is enabled or disabled based on some criteria present in the currently selected row.  ie: is a single row selected and is the URL column blank or not...

I started seeing that the DataGrid would come up disabled sometimes on some machines and not others.  It seems that what's happening here is that the datagrid gets disabled by this behavior if the command isn't enabled at the time the commandbehavior is being attached.  Once the DataGrid is disabled, selection isn't possible, so there's no way to get it enabled again.

I think you mention in your articles that CinchV2:SelectorDoubleClickCommandBehavior enables/disables the associated Framework UIElement based on whether the command can execute or not.

It would seem useful to have an option for SelectorDoubleClickCommandBehavior and EventToCommandTrigger that would bypass the enabling/disabling of the associated object.

Am I misunderstanding or misusing this?

Thanks!

Coordinator
Sep 29, 2012 at 4:19 PM
Edited Sep 29, 2012 at 4:20 PM

Sorry I only just noticed this

I did that for a good reason, but the best way to combat this would be simply grab my code for SelectorDoubleClickCommandBehavior. Thats what I like about WPF/Cinch, if you do not like my stuff just grab it change it and use your  SelectorDoubleClickCommandBehavior version

And take out the stuff that Enables/Disables the element. So remove this method

 

 private void EnableDisableElement()
        {
            if (AssociatedObject == null || Command == null)
            {
                return;
            }

            AssociatedObject.IsEnabled = Command.CanExecute(this.CommandParameter);
        }

 

Obviously if you do remove this, and the Command Can't run, it may fail for you somewhere else