简体   繁体   中英

WPF- MEF UX binding

WPF newb here. Consider the following situation

  • Parent user control A
  • Parent control has a placeholder / slot that these MEF extension User control can be loaded into dynamically.
  • All MEF extensions that provide a User control implement a specific interface. This includes a boolean that they can set to indicate an operation is complete.
  • Parent A has a button that needs to be enabled when the specific property(mentioned in the point above) is set to true.

Is this possible? If yes , how?

Is binding + INotifyPropertyChanged the way to go?

We've also thought of passing in Actions that can be used to update the state of the parent.

Are there any other alternatives?

So let me explain;

  1. if dynamically loaded user control has no data context (no view model is set), then user control uses view model of parent.
  2. But if you define a view model for each user control, you can import these view models and manage them in parent view model.
  3. Consider also using a BaseViewModel (BindableBase for MEF)

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