コード例 #1
0
        protected virtual bool GoToStateCore(Control control, IFrameworkElement templateRoot, string stateName, VisualStateGroup group, VisualState state, bool useTransitions)
        {
#if IS_UNO
            if (_trace.IsEnabled)
            {
                _trace.WriteEvent(
                    TraceProvider.StoryBoard_GoToState,
                    EventOpcode.Send,
                    new[] {
                    control.GetType()?.ToString(),
                    control?.GetDependencyObjectId().ToString(),
                    stateName,
                    useTransitions ? "UseTransitions" : "NoTransitions"
                }
                    );
            }
#endif

            var originalState = group.CurrentState;

            if (VisualState.Equals(originalState, state))
            {
                // Already in the right state
                return(true);
            }

            RaiseCurrentStateChanging(group, originalState, state);

            // The visual state group must not keep a hard reference to the control,
            // otherwise it may leak.
            var wr = Uno.UI.DataBinding.WeakReferencePool.RentWeakReference(this, control);

            group.GoToState(
                control,
                state,
                originalState,
                useTransitions,
                () =>
            {
                var innerControl = wr?.Target as Control;

                if (innerControl != null)
                {
                    RaiseCurrentStateChanged(group, originalState, state);
                }
            }
                );

            return(true);
        }