/// <summary>
        /// Begins listening to changes in the source object's dependency property
        /// </summary>
        /// <param name="dp">The property to observe</param>
        public void BindProperty(DependencyProperty dp)
        {
            DependencyPropertyDescriptor desc;

            if (!bindings.ContainsKey(dp))
            {
                desc = DependencyPropertyDescriptor.FromProperty(dp, source.GetType());
                //force that the dependency property belongs to the type of the object
                if (desc.IsAttached)//!source.GetType().IsAssignableFrom(dp.OwnerType))
                {
                    throw new ArgumentException("Invalid property");
                }
                //initially unbound
                bindings[dp] = new DependencyBinding(false, desc);
            }
            else
            {
                desc = bindings[dp].desc;
            }
            //refresh the value listener
            if (!bindings[dp].IsBound)
            {
                desc.AddValueChanged(source, dpChanged);
                bindings[dp].IsBound = true;
            }
        }
Beispiel #2
0
            private SingleDependencyView(Node parent, DependencyBinding binding, int index)
            {
                _Parent  = parent;
                _Binding = binding;
                _Index   = index;

                ViewCurrentPreviewCmd = new RelayCommand(() => { var view = NodeInstance; if (view != null)
                                                                 {
                                                                     view.SetAsCurrentResultView();
                                                                 }
                                                         }, arg => IsInstanced);

                if (_Index < 0)
                {
                    SetCurrentValueCmd = new RelayCommand(_SetNewDependencyNode, arg => IsEmpty);
                    ClearCurrentCmd    = new RelayCommand(_RemoveParameter, arg => IsInstanced);
                    SetCurrentEmptyCmd = new RelayCommand(_SetEmptyOverrideValue, arg => IsChildConfiguration && IsOwnValue);
                }
                else
                {
                    SetCurrentValueCmd = new RelayCommand(_SetNewDependencyNode, arg => IsEmpty);
                    ClearCurrentCmd    = new RelayCommand(_RemoveParameter, arg => true);
                    SetCurrentEmptyCmd = new RelayCommand(_SetEmptyOverrideValue, arg => false);
                }
            }
Beispiel #3
0
        public DependencyConfigToSemantics Bind <T>()
        {
            var dependencyBinding = new DependencyBinding()
            {
                FromType = typeof(T)
            };

            semanticModel.Bindings.Add(dependencyBinding);

            return(new DependencyConfigToSemantics(dependencyBinding));
        }
Beispiel #4
0
 public DependencyConfigScopingSemantics(DependencyBinding dependencyBinding)
 {
     this.dependencyBinding = dependencyBinding;
 }