Calling a Method of a UserControl in MVVM

前端 未结 7 583
温柔的废话
温柔的废话 2021-01-17 14:26

I\'m having an issue with calling a method on a UserControl. Hear me out:

  1. I have a UserControl someControl in SomeView.xaml

  2. Som

7条回答
  •  死守一世寂寞
    2021-01-17 15:09

    You're probably not going to like the answer, but your ViewModel should have no knowledge of your UI. If you have a non-UI method on your UserControl, it's probably in the wrong place.

    The only thing I could think of is that you may want to implement some type of messaging (like they have in MVVM Light) that could trigger the execution.

    It's either that, or rethink how you've architected your code.

提交回复
热议问题