views:

19

answers:

0

I'm trying to databind the visual state of a control (using code from the answer to http://stackoverflow.com/questions/2208363/visualstatemanager-and-databinding) to a property on my viewmodel in Silverlight.

On the viewmodel-side when I expose a standard property

Public Property State As String
    Get
        Return _state
    End Get
    Set(ByVal value As String)
        _state = value
        NotifyOfPropertyChange(Function() State)
    End Set
End Property

it works perfectly. However, I'd like to get rid of the backing field and expose it like this:

Public ReadOnly Property State As String
    Get
        Return _underlyingObject.State
    End Get
End Property

calling NotifyOfPropertyChanged manually when I need the UI to update.

Why doesn't the second method work? (I even tried to just return a fixed string or not making the property ReadOnly: as soon as I don't return the backing field it stops working)

Thanks for your insights.

[Edit: some more details] The XAML looks like this:

<HyperlinkButton
 utils:VisualState.VisualStateName="{Binding IsDocumentsActive, Converter={StaticResource BooleanLinkButtonVisualStateConverter}}" />

The converter is invoked even using the second method, but the PropertyChangedCallback on VisualStateNameProperty isn't called.