简体   繁体   中英

How to communicate between child control and parent window with big hierarchy in wpf?

There is big hierarchy of controls: window , inside window there is control, inside one more... All of them have view models. Before creating parent window , i generate some Field and pass as parameter of the window. I need to display the field on child control, how i can pass this field from parent's window view model to child control's view model not using the chain of properties/events/delegate commands and using mvvm ? What about ways to communicate between parent window and child control if there are many layers between?

The number of layers in between should be irrelevant if you follow the MVVM pattern. If for example all can happen in a single view model then there should be no issue. If however you have a separate view models as context for the window and a specific control, then it would be a good idea that the relationship gets reflected on the view model side, having the top view model contain the bottom one for example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM