Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVVM - Invoke Control Method

Tags:

c#

mvvm

wpf

I am looking for a MVVM solution. A Control is used in the View (lets call it V). The Control has a Method Foo(). That method can not be invoked by an event since its operation is not connected to any events of the control. I need to invoke this method from the ViewModel, but of course the ViewModel has no knowledge about the view. Do you have any ideas how to extend the Control to enable a MVVM compliant invocation of V.Foo()?

like image 560
Jaster Avatar asked Aug 25 '26 00:08

Jaster


1 Answers

I just checked my not accepted questions and found this one.
I remember I solved the issue by adding a ICommand dependecy property to the Control, which is bound using OneWayToSource with no updating. The Execute() call will call the method on the control.

like image 125
Jaster Avatar answered Aug 26 '26 15:08

Jaster