views:

39

answers:

1

So I think I'm doing something pretty basic. I know why this doesn't work, but it seems like there should be a straight foward way to make it work.

code:

private string fooImageRoot;
 // ....
 public BitmapImage FooImage
 {
  get
  {
   URI imageURI = new URI(Path.Combine(fooImageRoot, CurrentFooTypes.FooObject.FooImageName));
   return imageURI;
  }
 }

So CurrentFOoTypes and FooObject also supports INotifyPropertyChanged.

So If I bind a TextBlock to CurrentFooTypes.FooObject.FooImageName, if either fooObject or FooImageName change the textblock updates. How can I subscribe my viewmodel object to recieve updates in a similiar fasion.

A: 

Correct me if I'm wrong. You want to be notified of changes to the properties FooImageName and FooObject, both owning objects use INotifyPropertyChanged to alert observers that these properties have changed.

Josh Smith had a nice article where he introduced a PropertyObserver object, which is used for just this scenario.

The MVVM Foundation includes this object as well as other helpful objects for MVVM development.

You can use the PropertyObserver, or custom code, to watch for changes in the properties you're interested in (in this case FooObject and FooImageName) and perform whatever actions you need to update the image URI based on those changes.

Ed Gonzalez
Thank you that is exactly what I need.
Joel Barsotti