コード例 #1
0
        // Token: 0x06000CF1 RID: 3313 RVA: 0x0002FF14 File Offset: 0x0002E114
        private static bool GoToStateCommon(FrameworkElement control, FrameworkElement stateGroupsRoot, string stateName, bool useTransitions)
        {
            if (stateName == null)
            {
                throw new ArgumentNullException("stateName");
            }
            if (stateGroupsRoot == null)
            {
                return(false);
            }
            IList <VisualStateGroup> visualStateGroupsInternal = VisualStateManager.GetVisualStateGroupsInternal(stateGroupsRoot);

            if (visualStateGroupsInternal == null)
            {
                return(false);
            }
            VisualStateGroup group;
            VisualState      visualState;

            VisualStateManager.TryGetState(visualStateGroupsInternal, stateName, out group, out visualState);
            VisualStateManager customVisualStateManager = VisualStateManager.GetCustomVisualStateManager(stateGroupsRoot);

            if (customVisualStateManager != null)
            {
                return(customVisualStateManager.GoToStateCore(control, stateGroupsRoot, stateName, group, visualState, useTransitions));
            }
            return(visualState != null && VisualStateManager.GoToStateInternal(control, stateGroupsRoot, group, visualState, useTransitions));
        }
コード例 #2
0
ファイル: VisualStateManager.cs プロジェクト: ynkbt/moon
        /// <summary>
        ///     Transitions a control's state.
        /// </summary>
        /// <param name="control">The control who's state is changing.</param>
        /// <param name="stateName">The new state that the control is in.</param>
        /// <param name="useTransitions">Whether to use transition animations.</param>
        /// <returns>true if the state changed successfully, false otherwise.</returns>
        public static bool GoToState(Control control, string stateName, bool useTransitions)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            if (stateName == null)
            {
                throw new ArgumentNullException("stateName");
            }

            FrameworkElement root = VisualStateManager.GetTemplateRoot(control);

            if (root == null)
            {
                return(false); // Ignore state changes if a ControlTemplate hasn't been applied
            }

            IList <VisualStateGroup> groups = VisualStateManager.GetVisualStateGroupsInternal(root);

            if (groups == null)
            {
                return(false);
            }

            // System.Diagnostics.Debug.WriteLine("Going to " + stateName);
            VisualState      state;
            VisualStateGroup group;

            if (!VisualStateManager.TryGetState(groups, stateName, out group, out state))
            {
                return(false);
            }

            // Look for a custom VSM, and call it if it was found, regardless of whether the state was found or not.
            // This is because we don't know what the custom VSM will want to do. But for our default implementation,
            // we know that if we haven't found the state, we don't actually want to do anything.
            VisualStateManager customVsm = GetCustomVisualStateManager(root);

            if (customVsm != null)
            {
                return(customVsm.GoToStateCore(control, root, stateName, group, state, useTransitions));
            }
            else if (state != null)
            {
                return(GoToStateInternal(control, root, group, state, useTransitions));
            }

            return(false);
        }
コード例 #3
0
        /// <summary>
        ///     Transitions a control's state.
        /// </summary>
        /// <param name="control">The control who's state is changing.</param>
        /// <param name="stateGroupsRoot">The element to get the VSG & customer VSM from.</param>
        /// <param name="stateName">The new state that the control is in.</param>
        /// <param name="useTransitions">Whether to use transition animations.</param>
        /// <returns>true if the state changed successfully, false otherwise.</returns>
        private static bool GoToStateCommon(FrameworkElement control, FrameworkElement stateGroupsRoot, string stateName, bool useTransitions)
        {
            if (stateName == null)
            {
                throw new ArgumentNullException("stateName");
            }

            if (stateGroupsRoot == null)
            {
                return(false); // Ignore state changes if a stateGroupsRoot doesn't exist yet
            }

            IList <VisualStateGroup> groups = VisualStateManager.GetVisualStateGroupsInternal(stateGroupsRoot);

            if (groups == null)
            {
                return(false);
            }

            VisualState      state;
            VisualStateGroup group;

            VisualStateManager.TryGetState(groups, stateName, out group, out state);

            // Look for a custom VSM, and call it if it was found, regardless of whether the state was found or not.
            // This is because we don't know what the custom VSM will want to do. But for our default implementation,
            // we know that if we haven't found the state, we don't actually want to do anything.
            VisualStateManager customVsm = GetCustomVisualStateManager(stateGroupsRoot);

            if (customVsm != null)
            {
                return(customVsm.GoToStateCore(control, stateGroupsRoot, stateName, group, state, useTransitions));
            }
            else if (state != null)
            {
                return(GoToStateInternal(control, stateGroupsRoot, group, state, useTransitions));
            }

            return(false);
        }