tags:

views:

27

answers:

2

I have a custom user control that exposes a DepenencyProperty (ImageData).

I've placed this user control on a page and I bind it's ImageData property to a property of my page's ViewModel (photo).

<localControls:PhotoPicker ImageData="{Binding Path=Photo, Mode=TwoWay}"/>

When the user interact with the control setting the controls ImageData property the Photo property of my viewmodel is updated == Perfect. However if the ViewModel changes the value of Photo, the ImageData property of PhotoPicker is not changed. What could I be missing in getting data from the ViewModel back down to the user control?

UPDATE: Upon further investigation it seems that the setting from the ViewModel back to the control via the binding, through the dependencyproperty does not fire the setter of the dependency property wrapper property. What a mess. I need to know when that happens, if i can't do that in the setter of the wrapper property where should I do it?

UPDATE 2: Seems that the only way to find about changes to the DependencyProperty is to add a PropertyChangedCallback in the PropertyMetadata when Registering the property.

+1  A: 

http://karlshifflett.wordpress.com/2009/06/08/glimpse-for-silverlight-viewing-exceptions-and-binding-errors/

Rahul Soni
Thanks --- not exactly what I was looking for --- changed the question accordingly.
Ralph Shillington
+1  A: 

Sounds like your view model doesn't send property changed notifications? Extremely simplified, your view model must look something like this:

public class MyViewModel : INotifyPropertyChanged
{
    private object photo;

    public object Photo
    {
        get { return this.photo; }
        set { this.photo = value; this.OnPropertyChanged("Photo"); }
    }

    // ...
}
herzmeister der welten