Invoking a WPF command from a WPF-embedded Winforms control
-
19-09-2019 - |
Question
I have a WinDataGrid
class that extends from an Infragistics UltraGrid
. I have embedded my WinDataGrid
within a WPF usercontrol using WindowsFormHost
. When rows are selected, I need to invoke a predefined DelegateCommand<IList>
with my collection of selected rows.
How would I go about this?
As background, I have a WPF app that uses both a WPF DataGrid and an Infragistics WinGrid. The WPF grid is already mostly wired up, and I want to utilize the existing commands etc as much as possible in wiring up my Winforms grid. I realise there may be some mapping required, but figure I should be able to map most things?
Solution
If DelegateCommand
is an ICommand
you can call the Execute()
method to invoke the command. Don't forget to first check if the command is allowed to execute with CanExecute()