MVVM - what is the ideal way for usercontrols to talk to each other

后端 未结 9 1305
失恋的感觉
失恋的感觉 2020-12-08 05:24

I have a a user control which contains several other user controls. I am using MVVM. Each user control has a corresponding VM. How do these user controls send information to

9条回答
  •  悲&欢浪女
    2020-12-08 06:25

    You can communicate between elements on the UI by using element binding, so assuming a user control you created exposes a property, the other user controls could bind to it. You can configure the binding, use dependency properties instead of basic properties / implement INotifyPropertyChanged but it is in theory possible, but does require some forethought to enable to communication this way.

    You will probably find it far easier using a combination of events, code and properties than try a pure declarative way, but in theory possible.

提交回复
热议问题