質問

I have the following property in my view model and the view is binding to this property.

All works fine except for a special case where the ActiveCategory (within the _catManager) can change from other events (outside of this view).

I don't want to expose the entire Category Manager in the view model so I'm only exposing what properties I need. What is the best way to do this so that the view gets notified of all changes, even those changes not triggered within this view model?

 
    public ICategory SelectedCategory
     {
      get
       {
        return _catManager.ActiveCategory;
       }
      set
       {
        _catManager.ActiveCategory = value;
        OnPropertyChanged("SelectedCategory");
       }
     }
役に立ちましたか?

解決

Have your viewmodel hook into the _catManager's INotifyPropertyChanged event and have it relay the property change events through the viewmodel. When you see "ActiveCategory" come through, that means you need to raise an INPC for "SelectedCategory".

他のヒント

You need to delegate notification to whatever class _catManager is as well.

So a change to it's ActiveCategory property raises a notification.

One way would be to add a handler in the the class that has it as a property and then raise a notification that it's _catManager has changed somehow.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top