Current filter:
                                You should refresh the page.
                                  • I have an MVVM application and am using the DialogService to show a view where the user can select a record from a grid and click either an OK or Cancel button.  To ensure that they select a record before they click OK, I am passing UICommand's to the dialog service and the OK command has validation logic built into its CanExecute method.

                                    That all works correctly.  However, I would like to offer the user the option to double-click a record to effectively select it and click the OK button.  I can have the double-click trigger a command to close the dialog via the CurrentDialogService, but with that I only have the option to pass back a MessageResult, not a UICommand.

                                    Is there a way to programmatically close the dialog and return the UICommand for the OK option?

                                1 Solution

                                Creation Date Importance Sort by

                                I was able to figure out a solution.  I will post it here so others may benefit from it as I saw similar questions asked in the forum.

                                In my dialog view model, I defined two properties for the commands:

                                public UICommand OKCommand
                                public UICommand CancelCommand

                                Within my view I am using the EventToCommand behavior to execute a command in the view model when a record is double-clicked:

                                [C#]
                                <dxmvvm:Interaction.Behaviors> <dxmvvm:EventToCommand EventName="MouseDoubleClick" Command="{Binding SelectNodeCommand}" PassEventArgsToCommand="True" MarkRoutedEventsAsHandled="True"> <dxmvvm:EventToCommand.EventArgsConverter> <dx:EventArgsToDataRowConverter /> </dxmvvm:EventToCommand.EventArgsConverter> </dxmvvm:EventToCommand> </dxmvvm:Interaction.Behaviors>

                                The command that gets executed is defined as a POCO command and it calls the Close method on the CurrentDialogService and passes the UICommand so the ShowDialog method gets the correct response like this:

                                [C#]
                                public void SelectNode(StrategyNode node) { if (node != null) CurrentDialogService.Close(OKCommand); }