Assume that I have an application with the following structure:
(1) ViewModelA
(2) ReportManager
(3) ViewA
So - first, let me get the obvious out of the way. ViewA binds to ViewModelA.
Now for the not so obvious. ViewModelA has a singleton instance of ReportManager injected into it's constructor. ViewModelA exposes a 开发者_如何学JAVApublic read-only property called SomeReport. The getter for this property points to a property from the singleton instance of the ReportManager. Consider the following example below:
public ISomeViewModel SomeReport
{
get { return _reportManager.SomeReport; }
}
In ViewA, I have a ContentPresenter whose content property binds to the SomeReport property in ViewModelA - and because the SomeReport property in ViewModelA is read-only, I have set the binding up as OneWay.
Any and all changes made to the SomeReport property are made from within the ReportManager class - thus, this property has a private setter. The problem that I am running into is that the ContentPresenter in ViewA is not registering changes made to the SomeReport property.
Any help on what I am potentially doing incorrectly would be appreciated.
Thanks.
You can implement INotifyPropertyChanged on your ViewModel then signal that SomeReport has changed by calling NotifyPropertyChanged.
http://msdn.microsoft.com/en-us/library/ms229614.aspx
精彩评论