I defined the following two states in Expression Blend. I tried to follow this guide, but I feel that it leaves me hanging up when I need information on how and when to change state.

According to the manual, I have to attach behavior to my UserControl (I assume GotoState)). Unfortunately, I donβt think I really have User Control - and even if I did, would I have to attach the behavior to both my PortraitState and my LandscapeState ?
It seems I can attach a GotoState to a LayoutRoot element. So do I apply my behavior to this in both states? Any help would be greatly appreciated.
* edit: I played in my xaml.cs file and thought it might be a way to do this programmatically. when debugging and changing orientation, I enter my switch and find the correct orientation. However, the state never switches. What am I doing wrong?
protected override void OnOrientationChanged(OrientationChangedEventArgs e) { switch (e.Orientation) { case PageOrientation.Landscape: ExtendedVisualStateManager.GoToElementState(root:this.LayoutRoot, stateName: "LandscapeState", useTransitions: true); break; case PageOrientation.LandscapeRight: ExtendedVisualStateManager.GoToElementState(root:this.LayoutRoot, stateName: "LandscapeState", useTransitions: true); break; case PageOrientation.LandscapeLeft: ExtendedVisualStateManager.GoToElementState(root:LayoutRoot, stateName: "LandscapeState", useTransitions: true); break; case PageOrientation.Portrait: ExtendedVisualStateManager.GoToElementState(root:this.LayoutRoot, stateName: "PortraitState", useTransitions: true); break; case PageOrientation.PortraitUp: ExtendedVisualStateManager.GoToElementState(root:this.LayoutRoot, stateName: "PortraitState", useTransitions: true); break; case PageOrientation.PortraitDown: ExtendedVisualStateManager.GoToElementState(root:this.LayoutRoot, stateName: "PortraitState", useTransitions: true); break; default: break; } }
edit2: Trying above. It seems that GotoElementState returns false and, according to MSDN: "returns true if the control successfully transitions to a new state, otherwise false."
Now I have a question: what can lead to the failure of my condition?
CodePrimate
source share