Esempio n. 1
0
 internal void InvokeImpl(FrameworkElement stateTarget)
 {
     if (stateTarget != null)
     {
         VisualStateUtilities.GoToState(stateTarget, this.StateName, this.UseTransitions);
     }
 }
Esempio n. 2
0
        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);
            }
        }
        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);
                }
            }
        }