コード例 #1
0
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            IProvideValueTarget Target = (IProvideValueTarget)serviceProvider.GetService(typeof(IProvideValueTarget));

            if (Target.TargetObject is DependencyObject)
            {
                DependencyObject TargetObject = (DependencyObject)Target.TargetObject;

                ITagValueSettingStore PropertyStore = PersistentPropertyExtension.TryGetPropertyStoreFromResources(TargetObject);

                PropertyStoreAdapter StoreAdapter = PropertyStoreAdapter.GetInstanceFor(PropertyStore);

                SettingValue Value = new SettingValue(StoreAdapter, this.Name, this.DefaultValue, TargetObject);

                Binding SettingBinding = new Binding("Value");
                SettingBinding.Mode = BindingMode.TwoWay;
                SettingBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                SettingBinding.Source = Value;

                return(SettingBinding.ProvideValue(serviceProvider));
            }
            else
            {
                return(this);
            }
        }
コード例 #2
0
 public SettingValue(PropertyStoreAdapter propertyStore, string name, object defaultValue, DependencyObject target)
 {
     this.propertyStore = propertyStore;
     this.name          = name;
     this.defaultValue  = defaultValue;
     this.context       = PersistentProperty.GetIdPath(target);
     PersistentProperty.AddIDPathChangedEventHandler(target, this.ContextChanged);
     this.value = this.GetProperty();
     this.value.PropertyChanged += this.ValueChanged;
 }