Example #1
0
        public T GetAttachedPropertyValue <T>(string name, T defaultValue)
        {
            AbstractProperty property = GetAttachedProperty(name);

            return(property == null ? defaultValue : (T)property.GetValue());
        }
Example #2
0
            void OnExpandedChanged(AbstractProperty property, object oldvalue)
            {
                bool expanded = (bool)property.GetValue();

                _parent.RefreshOrClearSubPathItems(_directoryItem, !expanded);
            }
        public override void Restore(UIElement element)
        {
            IDataDescriptor  targetDd;
            DependencyObject targetObject;

            if (!FindPropertyDescriptor(element, out targetDd, out targetObject))
            {
                return;
            }
            AbstractProperty bindingsProperty = targetObject.GetOrCreateAttachedProperty(BINDING_SETTER_BINDINGS,
                                                                                         (IDictionary <BindingSetter, IBinding>) new Dictionary <BindingSetter, IBinding>());
            IDictionary <BindingSetter, IBinding> bindings = (IDictionary <BindingSetter, IBinding>)bindingsProperty.GetValue();
            IBinding binding;

            if (!bindings.TryGetValue(this, out binding))
            {
                return;
            }
            MPF.TryCleanupAndDispose(binding); // Also removes the binding from the binding collection in its context object
            bindings.Remove(this);
        }
        public override void Set(UIElement element)
        {
            // We must activate our bindings to make dynamic resource markup extensions assigning our binding work, for example
            ActivateBindings();
            if (_bindingWrapper == null || _bindingWrapper.Binding == null)
            {
                return;
            }
            IDataDescriptor  targetDd;
            DependencyObject targetObject;

            if (!FindPropertyDescriptor(element, out targetDd, out targetObject))
            {
                return;
            }
            AbstractProperty bindingsProperty = targetObject.GetOrCreateAttachedProperty(BINDING_SETTER_BINDINGS,
                                                                                         (IDictionary <BindingSetter, IBinding>) new Dictionary <BindingSetter, IBinding>());
            IDictionary <BindingSetter, IBinding> bindings = (IDictionary <BindingSetter, IBinding>)bindingsProperty.GetValue();

            if (bindings.ContainsKey(this))
            {
                return;
            }
            bindings.Add(this, _bindingWrapper.Binding.CopyAndRetarget(targetDd));
        }
Example #5
0
 private void OnRefreshIntervalChanged(AbstractProperty property, object oldvalue)
 {
     _animationTimer.Interval = (double)property.GetValue();
 }