internal void InvokeImpl(FrameworkElement stateTarget) { if (stateTarget != null) { VisualStateUtilities.GoToState(stateTarget, this.StateName, this.UseTransitions); } }
void Responsive() { if (this.ActualWidth > 700) { VisualStateUtilities.GoToState(this, "FullWindows", false); } else if (this.ActualWidth > 500) { VisualStateUtilities.GoToState(this, "Narrow", false); } else if (this.ActualWidth > 200) { VisualStateUtilities.GoToState(this, "ExtraNarrow", false); } else { VisualStateUtilities.GoToState(this, "Minimum", false); } if (Window.Current.Bounds.Height < 700) { RootGrid.Height = 60; } else { RootGrid.Height = 75; } }
private void MouseUp(object sender, MouseButtonEventArgs e) { if (!(Parent as MenuItem).IsSubmenuOpen) { VisualStateUtilities.GoToState(Parent, MouseUpState, true); } }
private void Evaluate() { if (TargetObject != null) { VisualStateUtilities.GoToState(stateName: (!ComparisonLogic.EvaluateImpl(Binding, ComparisonConditionType.Equal, Value)) ? FalseState : TrueState, element: TargetObject, useTransitions: true); } }
internal void InvokeImpl(FrameworkElement stateTarget) { if (stateTarget == null) { return; } VisualStateUtilities.GoToState(stateTarget, StateName, UseTransitions); }
protected override void Invoke(object parameter) { if (_stateTarget == null || StateName == null) { return; } VisualStateUtilities.GoToState(_stateTarget, StateName, UseTransitions); }
public void GoToState_OnCustomControlTemplate_WorksProperly() { string testStateName = "Test"; Button statefulButton = CreateButtonWithCustomState(testStateName); bool success = VisualStateUtilities.GoToState(statefulButton, testStateName, true); Assert.IsTrue(success, "GoToState on a valid state in a ControlTemplate should navigate to the state correctly."); }
void Responsive() { if (Window.Current.Bounds.Width < 1000) { VisualStateUtilities.GoToState(this, nameof(HalfSnap), false); } else { VisualStateUtilities.GoToState(this, nameof(Normal), false); } }
void Responsive() { if (Window.Current.Bounds.Width < 640) { VisualStateUtilities.GoToState(this, "Narrow", false); } else { VisualStateUtilities.GoToState(this, "Wide", false); } }
void Responsive(double width) { if (width <= 700) { VisualStateUtilities.GoToState(this, "Minimal", false); } else { VisualStateUtilities.GoToState(this, "Normal", false); } }
void Responsive(double width) { if (width <= 600) { VisualStateUtilities.GoToState(this, "Narrow", false); } else { VisualStateUtilities.GoToState(this, "Wide", false); } }
public void GoToState_OnUserControl_WorksProperly() { Grid stateGrid = VisualStateHelper.CreateObjectWithStates <Grid>(); UserControl userControl = CreateUserControlWithContent(stateGrid); userControl.Content = stateGrid; bool success = VisualStateUtilities.GoToState(userControl, VisualStateHelper.ArbitraryThirdStateName, true); Assert.IsTrue(success, "GoToState on a valid UserControl state should navigate to the state correctly."); }
public void UpdateVisualState(string visualState) { if (AssociatedObject != null) { FrameworkElement stateTarget; if (VisualStateUtilities.TryFindNearestStatefulControl(AssociatedObject, out stateTarget)) { bool useTransitions = _initialized; VisualStateUtilities.GoToState(stateTarget, visualState, useTransitions); _initialized = true; } } }
protected override void Invoke(object parameter) { if (this.AssociatedObject != null && _stateTarget != null) { var state = !string.IsNullOrWhiteSpace(this.StateName) ? this.StateName : parameter != null?parameter.ToString() : ""; if (!string.IsNullOrEmpty(state)) { VisualStateUtilities.GoToState(_stateTarget, state, this.UseTransitions); } } }
void Responsive() { if (Window.Current.Bounds.Width < 770) { VisualStateUtilities.GoToState(this, "Snap", false); } else if (Window.Current.Bounds.Width < 1000) { VisualStateUtilities.GoToState(this, "HalfSnap", false); } else { VisualStateUtilities.GoToState(this, "Normal", false); } }
private void SetVisualState() { if (AssociatedObject == null || DataEnum == null) { return; } var stateName = String.IsNullOrEmpty(FinalStateNameFormat) ? DataEnum.ToString() : String.Format(FinalStateNameFormat, DataEnum.ToString()); if (StateTarget == null) { return; } HookUptoCompletedEvent(StateTarget, stateName); VisualStateUtilities.GoToState(StateTarget, stateName, UseTransitions); }
private void UpdateVisualState( string visualState, bool useTransitions) { if (AssociatedObject != null) { FrameworkElement stateTarget; if (VisualStateUtilities.TryFindNearestStatefulControl( AssociatedObject, out stateTarget)) { VisualStateUtilities.GoToState( stateTarget, visualState, useTransitions); } } }
void Responsive(double width) { if (width <= 500) { VisualStateUtilities.GoToState(this, "Minimal", false); } #if WINDOWS_PHONE_APP else if (width < 500) #else else if (width < 870) #endif { VisualStateUtilities.GoToState(this, "Medium", false); } else { VisualStateUtilities.GoToState(this, "Normal", false); } }
private void Evaluate() { if (this.TargetObject != null) { string stateName = null; if (ComparisonLogic.EvaluateImpl(this.Binding, ComparisonConditionType.Equal, this.Value)) { stateName = this.TrueState; } else { stateName = this.FalseState; } VisualStateUtilities.GoToState(this.TargetObject, stateName, true); } }
protected override void InvokeAction(Livet.Messaging.InteractionMessage message) { var gtsm = message as GoToStateMessage; if (gtsm == null) { return; } try { gtsm.Response = VisualStateUtilities.GoToState( AssociatedObject, gtsm.StateName, gtsm.UseTransitions); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } }
/// <summary> /// This method invokes our VSM state /// </summary> /// <param name="parameter"></param> protected override void Invoke(object parameter) { if (base.Target != null) { string stateName = this.StateName; if (string.IsNullOrEmpty(stateName) && parameter is string) { stateName = parameter.ToString(); } // Locate the nearest state group var stateControl = VisualStateUtilities.FindNearestStatefulControl(base.Target); if (stateControl != null) { VisualStateUtilities.GoToState(stateControl, stateName, UseTransitions); } } }
internal void InvokeImpl(FrameworkElement stateTarget) { if (stateTarget != null && !string.IsNullOrEmpty(this.ActiveState) && !string.IsNullOrEmpty(this.InactiveState) && !string.IsNullOrEmpty(this.TargetScreen)) { UserControl screen = stateTarget .GetSelfAndAncestors() .OfType <UserControl>() .FirstOrDefault(control => control.GetType().ToString() == this.TargetScreen); string stateName = this.InactiveState; if (screen != null) { stateName = this.ActiveState; } if (!string.IsNullOrEmpty(stateName)) { ToggleButton toggleButton = stateTarget as ToggleButton; if (toggleButton != null) { switch (stateName) { case "Checked": toggleButton.IsChecked = true; return; case "Unchecked": toggleButton.IsChecked = false; return; } } if (stateName == "Disabled") { stateTarget.IsEnabled = false; return; } VisualStateUtilities.GoToState(stateTarget, stateName, true); } } }
void Responsive() { if (Window.Current.Bounds.Width > 500) { if (isWide) { return; } isWide = true; VisualStateUtilities.GoToState(this, "Wide", false); } else { if (!isWide) { return; } isWide = false; VisualStateUtilities.GoToState(this, "Narrow", false); } }
void Responsive() { BackgroundEffect.StartAnimation(); if (Window.Current.Bounds.Width < 650) { VisualStateUtilities.GoToState(this, "Snap", false); } else { VisualStateUtilities.GoToState(this, "Wide", false); } if (Window.Current.Bounds.Height < 600) { //HeaderGrid.Height = 100; VisualStateUtilities.GoToState(this, "Tiny", false); } else { VisualStateUtilities.GoToState(this, "Tall", false); } }
/// <summary> /// Executes the action. /// </summary> /// <param name="sender">The <see cref="System.Object"/> that is passed to the action by the behavior. Generally this is <seealso cref="Microsoft.Xaml.Interactivity.IBehavior.AssociatedObject"/> or a target object.</param> /// <param name="parameter">The value of this parameter is determined by the caller.</param> /// <returns>True if the transition to the specified state succeeds; else false.</returns> public object Execute(object sender, object parameter) { if (string.IsNullOrEmpty(this.StateName)) { return(false); } if (this.ReadLocalValue(GoToStateAction.TargetObjectProperty) != DependencyProperty.UnsetValue) { Control control = this.TargetObject as Control; if (control == null) { return(false); } return(VisualStateUtilities.GoToState(control, this.StateName, this.UseTransitions)); } FrameworkElement element = sender as FrameworkElement; if (element == null || !EventTriggerBehavior.IsElementLoaded(element)) { return(false); } Control resolvedControl = VisualStateUtilities.FindNearestStatefulControl(element); if (resolvedControl == null) { throw new InvalidOperationException(string.Format( CultureInfo.CurrentCulture, ResourceHelper.GoToStateActionTargetHasNoStateGroups, element.Name)); } return(VisualStateUtilities.GoToState(resolvedControl, this.StateName, this.UseTransitions)); }
private void OpenPlaylist_Click(object sender, RoutedEventArgs e) { VisualStateUtilities.GoToState(this, "Wide", false); }
private void SetVisualState() { if (AssociatedObject == null || !AssociatedObject.IsLoaded || DataEnum == null) { return; } var stateName = String.IsNullOrEmpty(FinalStateNameFormat) ? DataEnum.ToString() : String.Format(FinalStateNameFormat, DataEnum.ToString()); FrameworkElement stateTarget; var found = VisualStateUtilities.TryFindNearestStatefulControl(AssociatedObject, out stateTarget); if (!found) { stateTarget = AssociatedObject; } bool result = false; if (stateTarget != null) { var stateControl = stateTarget as Control; if (stateControl == null && found) { var groups = VisualStateManager.GetVisualStateGroups(stateTarget); if (groups.Count == 0) { groups = VisualStateManager.GetVisualStateGroups(AssociatedObject); } FindStoryboard(stateName, groups); result = VisualStateUtilities.GoToState(stateTarget, stateName, true); } else { var groups = VisualStateManager.GetVisualStateGroups(stateControl); if (groups.Count == 0) { groups = VisualStateManager.GetVisualStateGroups(AssociatedObject); } FindStoryboard(stateName, groups); result = VisualStateManager.GoToState(stateControl, stateName, true); } } //if (found) //{ // //bool useTransitions = _initialized; // VisualStateUtilities.GoToState(stateTarget, DataEnum.ToString(), true); // //_initialized = true; //} //else //{ // stateTarget = AssociatedObject as Control; // if (stateTarget != null) { // var result = VisualStateManager.GoToState(stateTarget, DataEnum.ToString(), true); // } //} #if DEBUG && DataBoundStateActionDEBUG Debug.WriteLine("DataBoundStateAction {0}, result={1}", DataEnum, result); #endif }
private void MouseEnter(object sender, MouseEventArgs e) { VisualStateUtilities.GoToState(Parent, MouseOverState, true); }
private void MouseDown(object sender, MouseButtonEventArgs e) { VisualStateUtilities.GoToState(Parent, MouseDownState, true); }