public static void Save()
 {
     using (Stream stream = File.Open(DirectoryHelper.Combine(CBRFolders.Cache, "ElementState.xml"), FileMode.Create, FileAccess.Write, FileShare.None))
     {
         ElementStateOperations.Save(stream);
     }
 }
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            IProvideValueTarget provideValue = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget;

            if (provideValue == null)
            {
                return(this);
            }

            DependencyObject   target   = provideValue.TargetObject as DependencyObject;
            DependencyProperty property = provideValue.TargetProperty as DependencyProperty;

            // If not dependency object or dependency property, return this instance
            if (target == null || property == null)
            {
                return(this);
            }

            if (!ElementStateOperations.HasPropertyValue(target, property))
            {
                object defaultValue = PropertyValueConverter.ConvertFromString(target.GetType(), property, Default);
                ElementStateOperations.AddPropertyValue(target, property, defaultValue);
            }

            BindingBase binding = ElementStateOperations.CreateBinding(target, property);

            object startValue = binding.ProvideValue(serviceProvider);

            return(startValue);
        }
 public static void Load()
 {
     using (Stream stream = File.Open(DirectoryHelper.Combine(CBRFolders.Cache, "ElementState.xml"), FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read))
     {
         ElementStateOperations.Load(stream);
     }
 }
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (ElementStateOperations.HasPropertyValue(Target, Property))
     {
         object propertyValue = ElementStateOperations.GetPropertyValue(Target, Property);
         return(propertyValue);
     }
     throw new ArgumentException(string.Format("The property {0}.{1} is not in state", Target, Property.Name));
 }