This project has moved and is read-only. For the latest updates, please go here.

Updating Imports when an Exported property changes

Jan 12, 2010 at 5:48 AM

I'm wondering if the following is possible, and if so, what the strategy is to make it happen.

I have a property I'm exporting, like so:


    public class TEMP : NotifyPropertyChangedBase
        private string myProperty = "My Value " + DateTime.Now;

        public string MyProperty
            get { return myProperty; }
                myProperty = value;

I then import "MyProperty" (obviously not using magic strings if I can help it)...and that's all good.

However, is there a way that if "MyProperty" changes I can force recomposition, and all "Imports" of "MyProperty" are subsequently updated?  

Just implementing INotifyPropertyChanged doesn't seem to do it.

[PS: I'm doing this in Silverlight...if that has any bearing on the approach]



Jan 12, 2010 at 7:23 PM

Unfortunately this approach will not work with MEF. Currently when a property is exported property value is only retrieved once and cached. If you want to be able to detect individual property changes you would need to export/import INotifyPropertyChanged or some other custom interface with an notification and listen for the change on the import side.

Jan 12, 2010 at 10:54 PM

Gotcha.  That makes sense.  Thanks.