Search code examples
expression-blenditemtemplatewindowstate

Blend 4 Change Window State using GoToStateAction behavior from within an ItemTemplate


I've been trying to get this working for a few hours now.

I have a Listbox control with items from a database in it. I have 2 window states, "default", and "details". I'd like to use the GoToStateAction behavior in the ItemTemplate so that when any item in the listbox is clicked it'll change the window state to "details".

I have been trying to set the TargetObject property of the behavior to the window, but I can't.

Am I missing something, or doing something wrong? Any help would be appreciated.


Solution

  • Have you tried TargetObject="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"?

    You might want to change the type to something like {x:Type local:MyWindowType}.