Пример #1
0
        private void GoToState(bool useTransitions)
        {
            if (IsLoaded && !DataPortal.IsInDesignMode)
            {
                DisablePopup(_lastImage);
                HandleTarget();

                FrameworkElement root = (FrameworkElement)Template.FindName("root", this);

                if (root != null)
                {
                    if (_isValid)
                    {
                        Storyboard validStoryboard = (Storyboard)Template.Resources["Valid"];
                        validStoryboard.Begin(root);
                    }
                    else
                    {
                        Storyboard errorStoryboard = (Storyboard)Template.Resources[_worst.ToString()];
                        errorStoryboard.Begin(root);
                        _lastImage = (FrameworkElement)Template.FindName(string.Format("{0}Image", _worst.ToString().ToLower()), this);
                        EnablePopup(_lastImage);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Updates the status of the Property in UI
        /// </summary>
        /// <param name="useTransitions">if set to <c>true</c> then use transitions.</param>
        protected virtual void GoToState(bool useTransitions)
        {
            if (_loading)
            {
                return;
            }

            BusyAnimation busy = FindChild(this, "busy") as BusyAnimation;

            if (busy != null)
            {
                busy.IsRunning = IsBusy;
            }

            string newState;

            if (IsBusy)
            {
                newState = "Busy";
            }
            else if (IsValid)
            {
                newState = "PropertyValid";
            }
            else
            {
                newState = RuleSeverity.ToString();
            }

            if (newState != _lastState || _lastImage == null)
            {
                _lastState = newState;
                DisablePopup(_lastImage);
                VisualStateManager.GoToState(this, newState, useTransitions);
                if (newState != "Busy" && newState != "PropertyValid")
                {
                    _lastImage = (FrameworkElement)FindChild(this, string.Format("{0}Image", newState.ToLower()));
                    EnablePopup(_lastImage);
                }
            }
        }