private void SaveState(FrameworkElement element, DependencyProperty property, string propertyName)
        {
            if (HasBindingExpression(element, property))
            {
                return;
            }

            string key = DependencyObjectHelper.GeneratePathString(element, this.GetType().FullName, element.GetType().FullName + "/" + propertyName);

            if (string.IsNullOrEmpty(key))
            {
                return;
            }

            dataStore[key] = element.GetValue(property);
        }
Пример #2
0
        private void PreserveState(Action <UserControl, VisualStateGroup, string> preserveStateAction)
        {
            UserControl      screen  = this.AssociatedObject;
            FrameworkElement content = screen.Content as FrameworkElement;

            IEnumerable <VisualStateGroup> groups = VisualStateManager.GetVisualStateGroups(content).OfType <VisualStateGroup>();

            foreach (VisualStateGroup group in groups)
            {
                string key = DependencyObjectHelper.GeneratePathString(screen, this.GetType().FullName, group.Name);
                if (string.IsNullOrEmpty(key))
                {
                    continue;
                }

                preserveStateAction(screen, group, key);
            }
        }