internal void InvokeImpl()

in src/Microsoft.Xaml.Behaviors/Core/PrototypingActions.cs [255:296]


        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);
                }
            }
        }