public static void SetBinding ( 
			DependencyObject target, 
			DependencyProperty property,
			Binding binding ) {

			throw new NotImplementedException ( );
		}
		public UIElement ()
		{
			InputBindings = new List<KeyBinding> ();

			visibility = BuildVisualProperty<Visibility> ("Visibility");
			focusable = BuildProperty<bool> ("Focusable");

			Mouse.PreviewButtonPressEvent += HandlePreviewButtonPressEvent;
			Mouse.ButtonPressEvent += HandleButtonPressEvent;

			Mouse.PreviewButtonReleaseEvent += OnPreviewButtonReleaseEvent;
			Mouse.ButtonReleaseEvent += OnButtonReleaseEvent;
			
			Mouse.PreviewMotionNotifyEvent += OnPreviewMotionNotifyEvent;
			Mouse.MotionNotifyEvent += OnMotionNotifyEvent;
			
			Mouse.MouseEnterEvent += OnMouseEnterEvent;
			Mouse.MouseLeaveEvent += OnMouseLeaveEvent;
			
			Keyboard.PreviewKeyPressEvent += OnPreviewKeyPressEvent;
			Keyboard.KeyPressEvent += OnKeyPressEvent;

			Keyboard.GotKeyboardFocusEvent += OnGotKeyboardFocusEvent;
			Keyboard.LostKeyboardFocusEvent += OnLostKeyboardFocusEvent;
		}
		public Selector ()
		{
			selectedItem = BuildProperty<UIElement> ("SelectedItem");
			selectedItem.DependencyPropertyValueChanged += HandleSelectedItemChanged;

			Items.CollectionChanged += HandleItemsChanged;
		}
 public DependencyPropertyChangedEventArgs(
     DependencyProperty property, object oldValue, object newValue)
 {
     Property = property;
     OldValue = oldValue;
     NewValue = newValue;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SingleAnimationGameAction" /> class.
 /// </summary>
 /// <param name="parent">The parent task.</param>
 /// <param name="singleAnimation">The single animation.</param>
 /// <param name="animation">The AnimationUI component.</param>
 /// <param name="dependencyProperty">The dependency property to animate.</param>
 public SingleAnimationGameAction(IGameAction parent, SingleAnimation singleAnimation, AnimationUI animation, DependencyProperty dependencyProperty)
     : base(parent, "SingleAnimationGameAction" + instances++)
 {
     this.animation = animation;
     this.singleAnimation = singleAnimation;
     this.dependencyProperty = dependencyProperty;
 }
		public SquareRootToken ()
		{
			child = BuildProperty<Token> ("Child");
			child.DependencyPropertyValueChanged += HandleValueChanged;

			Child = new TextToken ();
		}
Exemple #7
0
        public void ClearValue(DependencyProperty dp)
        {
            if (IsSealed)
                throw new InvalidOperationException("Cannot manipulate property values on a sealed Dependency Object");

            _properties[dp] = null;
        }
			public Helper(FrameworkElement obj, DependencyProperty property, Action<object, object> changed, object currentValue)
			{
				this.obj = obj;
				this.property = property; 
				this.changed = changed;
				this.currentValue = currentValue;
			}
		public DependencyPropertyChangedEventArgs (DependencyProperty property, object oldValue, object newValue)
			: this ()
		{
			this.Property = property;
			this.OldValue = oldValue;
			this.NewValue = newValue;
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="SingleAnimationGameAction" /> class.
 /// </summary>
 /// <param name="singleAnimation">The single animation.</param>
 /// <param name="animation">The AnimationUI component.</param>
 /// <param name="dependencyProperty">The dependency property to animate.</param>
 /// <param name="scene">The associated scene.</param>
 public SingleAnimationGameAction(SingleAnimation singleAnimation, AnimationUI animation, DependencyProperty dependencyProperty, Scene scene = null)
     : base("SingleAnimationGameAction" + instances++, scene)
 {
     this.animation = animation;
     this.singleAnimation = singleAnimation;
     this.dependencyProperty = dependencyProperty;
 }
		public SelfExpression (object obj)
		{
			item = BuildProperty<object> ("Item");
			item.Value = obj;

			Property = item;
		}
        /// <summary>
        /// Starts animating a dependency property of a framework element to a 
        /// target value.
        /// </summary>
        /// <param name="target">The element to animate.</param>
        /// <param name="animatingDependencyProperty">The dependency property to
        /// animate.</param>
        /// <param name="propertyPath">The path of the dependency property to 
        /// animate.</param>
        /// <param name="targetValue">The value to animate the dependency
        /// property to.</param>
        /// <param name="timeSpan">The duration of the animation.</param>
        /// <param name="easingFunction">The easing function to uses to
        /// transition the data points.</param>
        public static void BeginAnimation(
            this FrameworkElement target,
            DependencyProperty animatingDependencyProperty,
            string propertyPath,
            object targetValue,
            TimeSpan timeSpan)
        {
            Storyboard storyBoard = target.Resources[GetStoryboardKey(propertyPath)] as Storyboard;

            if (storyBoard != null)
            {
                // Save current value
                object currentValue = target.GetValue(animatingDependencyProperty);
                storyBoard.Stop();
                // Restore that value so it doesn't snap back to its starting value
                target.SetValue(animatingDependencyProperty, currentValue);
                target.Resources.Remove(GetStoryboardKey(propertyPath));
            }

            storyBoard = CreateStoryboard(target, animatingDependencyProperty, propertyPath, ref targetValue, timeSpan);

            storyBoard.Completed += 
                (source, args) =>
                    {
                        storyBoard.Stop();
                        target.SetValue(animatingDependencyProperty, targetValue);
                        target.Resources.Remove(GetStoryboardKey(propertyPath));
                    };

            target.Resources.Add(GetStoryboardKey(propertyPath), storyBoard);
            storyBoard.Begin();
        }
		public ButtonBase ()
		{
			command = BuildProperty<ICommand> ("Command");
			commandParameter = BuildProperty<object> ("CommandParameter");

			ButtonPressEvent += HandleButtonPressEvent;
		}
Exemple #14
0
    public void RunTest()
    {
        MHashTable *hash = create_hashtable();
        Map map;

        DependencyProperty dp1, dp2;

        dp1 = new DependencyProperty ();
        dp1.native = (IntPtr)0x01;
        dp1.name = "DP-0x01";

        map.obj = dp1;
        hash->Insert (dp1.native, map.intptr);

        dp2 = new DependencyProperty ();
        dp2.native = (IntPtr)0x02;
        dp2.name = "DP-0x02";

        map.obj = dp2;
        hash->Insert (dp2.native, map.intptr);

        IntPtr ip = hash->Lookup ((IntPtr)0x01);

        if (ip == IntPtr.Zero) {
            Console.WriteLine ("null!?");
        }
        else {
            map.intptr = ip;
            DependencyProperty prop = (DependencyProperty)map.obj;

            Console.WriteLine ("dp property = {0}", prop.name);
        }

        test_hashtable ((IntPtr)hash);
    }
        /// <summary>
        /// Inherited code: Requires comment.
        /// </summary>
        /// <param name="obj">Inherited code: Requires comment 1.</param>
        /// <param name="dependencyProperty">Inherited code: Requires comment 2.</param>
        /// <param name="suspend">Inherited code: Requires comment 3.</param>
        private static void SuspendHandler(this DependencyObject obj, DependencyProperty dependencyProperty, bool suspend)
        {
            if (_suspendedHandlers.ContainsKey(obj))
            {
                Dictionary<DependencyProperty, bool> suspensions = _suspendedHandlers[obj];

                if (suspend)
                {
                    Debug.Assert(!suspensions.ContainsKey(dependencyProperty), "Suspensions should not contain the property!");

                    // true = dummy value
                    suspensions[dependencyProperty] = true;
                }
                else
                {
                    Debug.Assert(suspensions.ContainsKey(dependencyProperty), "Suspensions should contain the property!");
                    suspensions.Remove(dependencyProperty);
                    if (suspensions.Count == 0)
                    {
                        _suspendedHandlers.Remove(obj);
                    }
                }
            }
            else
            {
                Debug.Assert(suspend, "suspend should be true!");
                _suspendedHandlers[obj] = new Dictionary<DependencyProperty, bool>();
                _suspendedHandlers[obj][dependencyProperty] = true;
            }
        }
 public override object GetValueCore(DependencyObject d, DependencyProperty dp)
 {
     if (Source != null)
         return GetValueCore(Source);
     if (ElementName == null)
         if (d is FrameworkElement)
         {
             FrameworkElement element = (FrameworkElement)d;
             while (element != null)
             {
                 if (element.DataContext != null)
                     return GetValueCore(element.DataContext);
                 element = element.VisualParent as FrameworkElement;
             }
             return null;
         }
         else
             return null;
     if ((d is Visual) && dp == NameScope.NameScopeProperty)
         return null;
     INameScope nameScope = NameScope.GetNameScope(d);
     if (nameScope == null)
         return null;
     object source = nameScope.FindName(ElementName);
     return GetValueCore(source);
 }
Exemple #17
0
        private static void SuspendHandler(this DependencyObject obj, DependencyProperty dependencyProperty, bool suspend)
        {
            if (_suspendedHandlers.ContainsKey(obj))
            {
                Dictionary<DependencyProperty, bool> suspensions = _suspendedHandlers[obj];

                if (suspend)
                {
                    Debug.Assert(!suspensions.ContainsKey(dependencyProperty));
                    suspensions[dependencyProperty] = true; // 
                }
                else
                {
                    Debug.Assert(suspensions.ContainsKey(dependencyProperty));
                    suspensions.Remove(dependencyProperty);
                    if (suspensions.Count == 0)
                    {
                        _suspendedHandlers.Remove(obj);
                    }
                }
            }
            else
            {                
                Debug.Assert(suspend);
                _suspendedHandlers[obj] = new Dictionary<DependencyProperty, bool>();
                _suspendedHandlers[obj][dependencyProperty] = true;
            }
        }
        private static void SuspendHandler(this DependencyObject obj, DependencyProperty dependencyProperty, bool suspend)
        {
            if (_suspendedHandlers.ContainsKey(obj))
            {
                Dictionary<DependencyProperty, bool> suspensions = _suspendedHandlers[obj];

                if (suspend)
                {
                    Debug.Assert(!suspensions.ContainsKey(dependencyProperty), "suspensions unexpectedly contain dependencyProperty");
                    suspensions[dependencyProperty] = true; // true = dummy value
                }
                else
                {
                    Debug.Assert(suspensions.ContainsKey(dependencyProperty), "suspensions unexpectedly do not contain dependencyProperty");
                    suspensions.Remove(dependencyProperty);
                    if (suspensions.Count == 0)
                    {
                        _suspendedHandlers.Remove(obj);
                    }
                }
            }
            else
            {
                Debug.Assert(suspend, "suspend unexpectedly false");
                _suspendedHandlers[obj] = new Dictionary<DependencyProperty, bool>();
                _suspendedHandlers[obj][dependencyProperty] = true;
            }
        }
        internal static void _OnApplyProperty(TextEditor This, DependencyProperty formattingProperty, object propertyValue, bool applyToParagraphs, PropertyValueAction propertyValueAction)
        {
            if (This == null || !This._IsEnabled || This.IsReadOnly || !This.AcceptsRichContent || !(This.Selection is TextSelection))
            {
                return;
            }

            // Check whether the property is known
            if (!TextSchema.IsParagraphProperty(formattingProperty) && !TextSchema.IsCharacterProperty(formattingProperty))
            {
                Invariant.Assert(false, "The property '" + formattingProperty.Name + "' is unknown to TextEditor");
                return;
            }

            TextSelection selection = (TextSelection)This.Selection;

            if (TextSchema.IsStructuralCharacterProperty(formattingProperty) &&
                !TextRangeEdit.CanApplyStructuralInlineProperty(selection.Start, selection.End))
            {
                // Ignore structural commands fires in inappropriate context.
                return;
            }

            TextEditorTyping._FlushPendingInputItems(This);

            // Forget previously suggested horizontal position
            TextEditorSelection._ClearSuggestedX(This);

            // Break merged typing sequence
            TextEditorTyping._BreakTypingSequence(This);

            // Apply property
            selection.ApplyPropertyValue(formattingProperty, propertyValue, applyToParagraphs, propertyValueAction);
        }
 public BindingTarget()
 {
     PositionProperty = new DependencyProperty<Vector3>(
         new BindingFactory(),
         new Vector3(),
         PropertyChangedCallback,
         null);
 }
Exemple #21
0
		public object GetPropertyValue (DependencyProperty formattingProperty)
		{
			// note: SL4 does a NRE so 'formattingProperty.Native' without a null check is "ok"
			IntPtr val = NativeMethods.text_selection_get_property_value (native, formattingProperty.Native);
			if (val == IntPtr.Zero)
				return DependencyProperty.UnsetValue;
			return Value.ToObject (null, val);
		}
        private void SetItemBinding(SwipeListViewItem item, string origin, DependencyProperty destination)
        {
            var binding = new Binding();
            binding.Source = this;
            binding.Path = new PropertyPath(origin);

            BindingOperations.SetBinding(item, destination, binding);
        }
        public PropertyValidationContext(object propertyOwner, DependencyProperty dependencyProperty)
        {
            if (propertyOwner == null)
                throw new ArgumentNullException("propertyOwner");

            this.propertyOwner = propertyOwner;
            this.propertyInfo = dependencyProperty;
        }
 public ButtonBinding()
 {
     CommandProperty = new DependencyProperty<ICommand>(
         new BindingFactory(),
         null,
         CommandPropertyChangedCallback,
         null);
 }
Exemple #25
0
 protected override void OnPropertyChanged(DependencyProperty property, object newValue, object oldValue)
 {
     if (property == BackgroundProperty)
     {
         border.Background = (Brush)newValue;
     }
     base.OnPropertyChanged(property, newValue, oldValue);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="UvmlDependencyPropertyBindingMutator"/> class.
        /// </summary>
        /// <param name="dpropID">The property which is being mutated.</param>
        /// <param name="dpropValue">The value to set on the property.</param>
        public UvmlDependencyPropertyBindingMutator(DependencyProperty dpropID, UvmlNode dpropValue)
        {
            Contract.Require(dpropID, nameof(dpropID));
            Contract.Require(dpropValue, nameof(dpropValue));

            this.dpropID = dpropID;
            this.dpropValue = dpropValue;
        }
        /// <summary>
        /// Returns a value that indicates whether the specified property is currently data-bound.
        /// </summary>
        /// <param name="target">The object where <paramref name="property"/> is.</param>
        /// <param name="property">The dependency property to check.</param>
        /// <returns>True if the specified property is data-bound, otherwise False.</returns>
        public static bool IsDataBound(DependencyObject target, DependencyProperty property)
        {
#if NETFX_CORE
            return target.ReadLocalValue(property) is BindingExpressionBase;
#else
            return BindingOperations.IsDataBound(target, property);
#endif
        }
            public DependencyPropertyRegistration(FrameworkElement frameworkElement, DependencyProperty dependencyProperty, Action<object, object> propertyChangedCallback, object currentValue)
            {
                FrameworkElement = frameworkElement;
                DependencyProperty = dependencyProperty;
                PropertyChangedCallback = propertyChangedCallback;

                _currentValue = currentValue;
            }
 static ConditionTypeConverter()
 {
     RuleConditionReferenceType = Type.GetType("System.Workflow.Activities.Rules.RuleDefinitions, " + AssemblyRef.ActivitiesAssemblyRef);
     RuleDefinitionsType = Type.GetType("System.Workflow.Activities.Rules.RuleConditionReference, " + AssemblyRef.ActivitiesAssemblyRef);
     CodeConditionType = Type.GetType("System.Workflow.Activities.CodeCondition, " + AssemblyRef.ActivitiesAssemblyRef);
 
     DeclarativeConditionDynamicProp = (DependencyProperty)RuleConditionReferenceType.GetField("RuleDefinitionsProperty").GetValue(null);
 }
		public MenuItem ()
		{
			isSubmenuOpen = BuildProperty<bool> ("IsSubmenuOpen");

			GetProperty ("Header").DependencyPropertyValueChanged += HandleHeaderChanged;

			StyleHelper.ApplyStyle (this, typeof(MenuItem));
		}
Exemple #31
0
 public PropertyLogger(DependencyObject o, DependencyProperty property, bool stack = false)
 {
     O          = o;
     Property   = property;
     this.stack = stack;
 }
        static void RenderElementsAndRaiseChangedEventOnAllDependencyProperties(DependencyObject dependencyObject)
        {

            //#if CSHTML5BLAZOR && DEBUG
            //            string prettyPrintDependencyObject = dependencyObject + (dependencyObject != null ? "(" + dependencyObject.GetHashCode().ToString() +")" : "");
            //            Console.WriteLine("OPENSILVER DEBUG: VisualTreeManager: RenderElementsAndRaiseChangedEventOnAllDependencyProperties: dependencyObject:" + prettyPrintDependencyObject);
            //#endif

            // To prevent raising the property multiple times, we keep track of the properties for which we already raised the "PropertyChanged" event:
            //Dictionary<DependencyProperty, DependencyProperty> propertiesForWhichTheEventHasAlreadyBeenRaised = new Dictionary<DependencyProperty, DependencyProperty>(); //todo: replace with HashSet<DependencyProperty> when available.

            //------------------------------------------------------------------------------------------------------------------
            // RAISE "PROPERTYCHANGED" FOR ALL THE PROPERTIES THAT HAVE A VALUE THAT HAS BEEN SET, INCLUDING ATTACHED PROPERTIES, AND CALL THE "METHOD TO UPDATE DOM":
            //------------------------------------------------------------------------------------------------------------------

            // This is used to force a redraw of all the properties that are set on the object (including Attached Properties!). For example, if a Border has a colored background, this is the moment when that color will be applied. Properties that have no value set by the user are not concerned (their default state is rendered elsewhere).
            if (dependencyObject.INTERNAL_PropertyStorageDictionary != null)
            {
#if PERFSTAT
                var t0 = Performance.now();
#endif
                var list = dependencyObject.INTERNAL_PropertyStorageDictionary.ToList<KeyValuePair<DependencyProperty, INTERNAL_PropertyStorage>>(); //we copy the Dictionary so that the foreach doesn't break when we modify a DependencyProperty inside the Changed of another one (which causes it to be added to the Dictionary).
#if PERFSTAT
                Performance.Counter("VisualTreeManager: Copy list of properties", t0);
#endif
                foreach (KeyValuePair<DependencyProperty, INTERNAL_PropertyStorage> propertiesAndTheirStorage in list)
                {
                    // Read the value:
                    DependencyProperty property = propertiesAndTheirStorage.Key;

#if PERFSTAT
                    var t1 = Performance.now();
#endif

                    PropertyMetadata propertyMetadata = property.GetTypeMetaData(dependencyObject.GetType());
                    //#if CSHTML5BLAZOR && DEBUG
                    //                    string prettyPrintProperty = property.Name + (property != null ? "(" + property.GetHashCode().ToString() + ")" : "");
                    //                    Console.WriteLine("OPENSILVER DEBUG: VisualTreeManager: RenderElementsAndRaiseChangedEventOnAllDependencyProperties:"
                    //                        + " dependencyObject:" + prettyPrintDependencyObject
                    //                        + " property:" + prettyPrintProperty
                    //                        + " MSG: " + (propertyMetadata != null ? "has" : "has not") + " a propertyMetadata");
                    //#endif
                    if (propertyMetadata != null)
                    {
                        INTERNAL_PropertyStorage storage = propertiesAndTheirStorage.Value;
                        object value = null;
                        bool valueWasRetrieved = false;

                        //--------------------
                        // Call "Apply CSS", which uses "GetCSSEquivalent/s":
                        //--------------------
                        if (propertyMetadata.GetCSSEquivalent != null || propertyMetadata.GetCSSEquivalents != null)
                        {
                            if (!valueWasRetrieved)
                            {
                                value = INTERNAL_PropertyStore.GetValue(storage, propertyMetadata);
                                valueWasRetrieved = true;
                            }

                            INTERNAL_PropertyStore.ApplyCssChanges(value, value, propertyMetadata, storage.Owner);
                        }

                        //--------------------
                        // Call "MethodToUpdateDom":
                        //--------------------
                        if (propertyMetadata.MethodToUpdateDom != null)
                        {
                            if (!valueWasRetrieved)
                            {
                                value = INTERNAL_PropertyStore.GetValue(storage, propertyMetadata);
                                valueWasRetrieved = true;
                            }

                            // Call the "Method to update DOM":
                            propertyMetadata.MethodToUpdateDom(storage.Owner, value);
                        }

                        //--------------------
                        // Call PropertyChanged:
                        //--------------------
                        //#if CSHTML5BLAZOR && DEBUG
                        //                        string prettyPrintPropertyMetadata = propertyMetadata + (propertyMetadata != null ? propertyMetadata.GetHashCode().ToString() : "");
                        //                        Console.WriteLine("OPENSILVER DEBUG: VisualTreeManager: RenderElementsAndRaiseChangedEventOnAllDependencyProperties:"
                        //                            + " dependencyObject:" + prettyPrintDependencyObject
                        //                            + " property:" + prettyPrintProperty
                        //                            + " propertyMetadata:" + propertyMetadata
                        //                            + " MSG: " + (propertyMetadata.PropertyChangedCallback != null ? "has" : "has not") + " a PropertyChangedCallback" );
                        //#endif
                        if (propertyMetadata.PropertyChangedCallback != null
                            && propertyMetadata.CallPropertyChangedWhenLoadedIntoVisualTree != WhenToCallPropertyChangedEnum.Never)
                        {
                            if (!valueWasRetrieved)
                            {
                                value = INTERNAL_PropertyStore.GetValue(storage, propertyMetadata);
                                valueWasRetrieved = true;
                            }

                            //#if CSHTML5BLAZOR && DEBUG
                            //                            Console.WriteLine("OPENSILVER DEBUG: VisualTreeManager: RenderElementsAndRaiseChangedEventOnAllDependencyProperties:" 
                            //                                + " dependencyObject:" + prettyPrintDependencyObject 
                            //                                + " property:" + prettyPrintProperty 
                            //                                + " propertyMetadata:" + propertyMetadata
                            //                                + " MSG: is raising PropertyChangedCallback)");
                            //#endif
                            // Raise the "PropertyChanged" event:
                            propertyMetadata.PropertyChangedCallback(storage.Owner, new DependencyPropertyChangedEventArgs(value, value, property));

                            // Remember that we raised the event, to avoid raising it again in the code below:
                            //propertiesForWhichTheEventHasAlreadyBeenRaised.Add(property, property); //commented since the "code below" is commented
                        }
                    }


#if PERFSTAT
                    Performance.Counter("VisualTreeManager: RaisePropertyChanged for property '" + property.Name + "'", t1);
#endif
                }
            }
            /*
            //------------------------------------------------------------------------------------
            // RAISE "PROPERTYCHANGED" FOR ALL THE OTHER PROPERTIES THAT REQUIRE IT
            //------------------------------------------------------------------------------------

            // When a dependency property is not set, we usually do not raise the "PropertyChanged" event, unless the property has its "CallPropertyChangedWhenLoadedIntoVisualTree" property set to "Always" in its TypeMetadata:
            var type = dependencyObject.GetType();
            // Iterate through all the inheritance parents of the type (we use a Stack to revert the order):
            Stack<Type> typeAndItsInheritanceParents = new Stack<Type>();
            while (type != null)
            {
                typeAndItsInheritanceParents.Push(type);
                type = type.BaseType;
            }
            while (typeAndItsInheritanceParents.Count > 0)
            {
                type = typeAndItsInheritanceParents.Pop();
                if (INTERNAL_TypeToDependencyPropertiesThatRequirePropertyChanged.TypeToDependencyPropertiesThatRequirePropertyChanged.ContainsKey(type))
                {
                    // Raise the "PropertyChanged" for all the DependencyProperties of the object that require it:
                    foreach (DependencyProperty dependencyProperty in INTERNAL_TypeToDependencyPropertiesThatRequirePropertyChanged.TypeToDependencyPropertiesThatRequirePropertyChanged[type])
                    {
                        if (!propertiesForWhichTheEventHasAlreadyBeenRaised.ContainsKey(dependencyProperty)
                            && dependencyProperty.TypeMetadata.PropertyChangedCallback != null)
                        {
                            // Get the value:
                            object value;
                            if (dependencyObject.INTERNAL_PropertyStorageDictionary.ContainsKey(dependencyProperty))
                                value = dependencyObject.GetValue(dependencyProperty);
                            else if (dependencyProperty.TypeMetadata != null)
                                value = dependencyProperty.TypeMetadata.DefaultValue;
                            else
                                value = null;

                            // Raise the "PropertyChanged":
                            dependencyProperty.TypeMetadata.PropertyChangedCallback(dependencyObject, new DependencyPropertyChangedEventArgs(value, value, dependencyProperty));
                        }
                    }
                }
            }
             */
        }
Exemple #33
0
 public BindingExpressionBase SetBinding(DependencyProperty property, BindingBase binding)
 {
     return(BindingOperations.SetBinding(this, property, binding));
 }
Exemple #34
0
 void OnIsPaneOpenChanged(DependencyObject sender, DependencyProperty dp)
 {
     ((IElementController)Element).SetValueFromRenderer(MasterDetailPage.IsPresentedProperty, Control.IsPaneOpen);
     UpdateBounds();
 }
 static SecEditorControl()
 {
     HitListProperty = DependencyProperty.Register("HitList", typeof(ObservableCollection <DependencyObject>), typeof(SecEditorControl),
                                                   new PropertyMetadata(null));
 }
Exemple #36
0
 public static void SetIsOpenProperty(DependencyObject obj, DependencyProperty menu)
 {
     obj.SetValue(IsOpenPropertyProperty, menu);
 }
Exemple #37
0
 public object GetValue(DependencyProperty dp)
 {
     return(Frame.GetValue(dp));
 }
 public CodeGeneratorProperty(DependencyProperty property, object value)
 {
     Property = property;
     Value    = value;
 }
 public static void SetUpdateSourceOnEnterProperty(DependencyObject instance, DependencyProperty value)
 {
     instance.SetValue(UpdateSourceOnEnterProperty, value);
 }
Exemple #40
0
 private IDisposable RegisterCallback(DependencyProperty property, Action callback)
 {
     return(this.RegisterDisposablePropertyChangedCallback(property, (_, __) => callback()));
 }
        void UpdateItemCheckedState(ToggleButton button, DependencyProperty formattingProperty, object expectedValue)
        {
            object currentValue = Target.Selection.GetPropertyValue(formattingProperty);

            button.IsChecked = (currentValue == DependencyProperty.UnsetValue) ? false : currentValue != null && currentValue.Equals(expectedValue);
        }
 /// <summary> Calls <see cref="DependencyObject.GetValue(DependencyProperty)"/> of the specified property and casts the result into the given type. </summary>
 /// <typeparam name="T"> The type to cast into. </typeparam>
 /// <param name="dependencyObject"> The source object. </param>
 /// <param name="dependencyProperty"> The property to get the value of. </param>
 /// <returns></returns>
 public static T GetValue <T>(this DependencyObject dependencyObject, DependencyProperty dependencyProperty) =>
 (T)dependencyObject.GetValue(dependencyProperty);
Exemple #43
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="AnimationManager" /> class.
 /// </summary>
 /// <param name="animationProperty">The animation property.</param>
 public AnimationManager(DependencyProperty animationProperty)
 {
     this.animationProperty = animationProperty;
     this.animationQueue    = new Queue <AnimationItem>();
     this.activeAnimations  = new List <AnimationItem>();
 }
 /// <summary>
 /// Attaches a binding to a FrameworkElement, using the provided binding object.
 /// </summary>
 /// <param name="dependencyProperty">The dependency property identifier of the property that is data bound.</param>
 /// <param name="binding">The binding to use for the property.</param>
 /// <returns>The BindingExpression created.</returns>
 public BindingExpression SetBinding(DependencyProperty dependencyProperty, Binding binding)
 {
     return(BindingOperations.SetBinding(this, dependencyProperty, binding));
 }
 private void ToggleBackgroundChanged(DependencyObject o, DependencyProperty p)
 {
     UpdateToggleBackgroundColor(o as Button);
 }
 public BindingExpression GetBindingExpression(DependencyProperty dp)
 {
     return(BindingOperations.GetBindingExpression(this, dp));
 }
Exemple #47
0
 public void SetValue(DependencyProperty dp, object value)
 {
     Frame.SetValue(dp, value);
 }
 static ListFindClientControl()
 {
     ItemsSourceProperty = DependencyProperty.Register("ItemsSource", typeof(List <string>), typeof(ListFindClientControl));
 }
Exemple #49
0
 public void ClearValue(DependencyProperty dp)
 {
     Frame.ClearValue(dp);
 }
Exemple #50
0
 private static void ApplyBinding(BindingBase binding, DependencyObject target, DependencyProperty property)
 {
     if (binding != null)
     {
         BindingOperations.SetBinding(target, property, binding);
     }
     else
     {
         BindingOperations.ClearBinding(target, property);
     }
 }
 static TaskList()
 {
     CurrentItemProperty = DependencyProperty.Register("CurrentItem", typeof(string), typeof(TaskList));            
 }
 public override object ProvideValue(object target, DependencyProperty property)
 {
     return(_ProvideValue(target, property.Name));
 }
 void SplitViewDisplayModeChanged(DependencyProperty dp) => DisplayMode = ShellSplitView.DisplayMode;
Exemple #54
0
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        static TileBrush()
        {
            // We check our static default fields which are of type Freezable
            // to make sure that they are not mutable, otherwise we will throw
            // if these get touched by more than one thread in the lifetime
            // of your app.

            RenderOptions.CachingHintProperty.OverrideMetadata(
                typeof(TileBrush),
                new UIPropertyMetadata(CachingHint.Unspecified,
                                       new PropertyChangedCallback(CachingHintPropertyChanged)));

            RenderOptions.CacheInvalidationThresholdMinimumProperty.OverrideMetadata(
                typeof(TileBrush),
                new UIPropertyMetadata(0.707,
                                       new PropertyChangedCallback(CacheInvalidationThresholdMinimumPropertyChanged)));

            RenderOptions.CacheInvalidationThresholdMaximumProperty.OverrideMetadata(
                typeof(TileBrush),
                new UIPropertyMetadata(1.414,
                                       new PropertyChangedCallback(CacheInvalidationThresholdMaximumPropertyChanged)));

            // Initializations
            Type typeofThis = typeof(TileBrush);

            ViewportUnitsProperty =
                RegisterProperty("ViewportUnits",
                                 typeof(BrushMappingMode),
                                 typeofThis,
                                 BrushMappingMode.RelativeToBoundingBox,
                                 new PropertyChangedCallback(ViewportUnitsPropertyChanged),
                                 new ValidateValueCallback(System.Windows.Media.ValidateEnums.IsBrushMappingModeValid),
                                 /* isIndependentlyAnimated  = */ false,
                                 /* coerceValueCallback */ null);
            ViewboxUnitsProperty =
                RegisterProperty("ViewboxUnits",
                                 typeof(BrushMappingMode),
                                 typeofThis,
                                 BrushMappingMode.RelativeToBoundingBox,
                                 new PropertyChangedCallback(ViewboxUnitsPropertyChanged),
                                 new ValidateValueCallback(System.Windows.Media.ValidateEnums.IsBrushMappingModeValid),
                                 /* isIndependentlyAnimated  = */ false,
                                 /* coerceValueCallback */ null);
            ViewportProperty =
                RegisterProperty("Viewport",
                                 typeof(Rect),
                                 typeofThis,
                                 new Rect(0, 0, 1, 1),
                                 new PropertyChangedCallback(ViewportPropertyChanged),
                                 null,
                                 /* isIndependentlyAnimated  = */ true,
                                 /* coerceValueCallback */ null);
            ViewboxProperty =
                RegisterProperty("Viewbox",
                                 typeof(Rect),
                                 typeofThis,
                                 new Rect(0, 0, 1, 1),
                                 new PropertyChangedCallback(ViewboxPropertyChanged),
                                 null,
                                 /* isIndependentlyAnimated  = */ true,
                                 /* coerceValueCallback */ null);
            StretchProperty =
                RegisterProperty("Stretch",
                                 typeof(Stretch),
                                 typeofThis,
                                 Stretch.Fill,
                                 new PropertyChangedCallback(StretchPropertyChanged),
                                 new ValidateValueCallback(System.Windows.Media.ValidateEnums.IsStretchValid),
                                 /* isIndependentlyAnimated  = */ false,
                                 /* coerceValueCallback */ null);
            TileModeProperty =
                RegisterProperty("TileMode",
                                 typeof(TileMode),
                                 typeofThis,
                                 TileMode.None,
                                 new PropertyChangedCallback(TileModePropertyChanged),
                                 new ValidateValueCallback(System.Windows.Media.ValidateEnums.IsTileModeValid),
                                 /* isIndependentlyAnimated  = */ false,
                                 /* coerceValueCallback */ null);
            AlignmentXProperty =
                RegisterProperty("AlignmentX",
                                 typeof(AlignmentX),
                                 typeofThis,
                                 AlignmentX.Center,
                                 new PropertyChangedCallback(AlignmentXPropertyChanged),
                                 new ValidateValueCallback(System.Windows.Media.ValidateEnums.IsAlignmentXValid),
                                 /* isIndependentlyAnimated  = */ false,
                                 /* coerceValueCallback */ null);
            AlignmentYProperty =
                RegisterProperty("AlignmentY",
                                 typeof(AlignmentY),
                                 typeofThis,
                                 AlignmentY.Center,
                                 new PropertyChangedCallback(AlignmentYPropertyChanged),
                                 new ValidateValueCallback(System.Windows.Media.ValidateEnums.IsAlignmentYValid),
                                 /* isIndependentlyAnimated  = */ false,
                                 /* coerceValueCallback */ null);
        }
Exemple #55
0
        public IObservable <IObservedChange <object, object> > GetNotificationForProperty(object sender, string propertyName, bool beforeChanged = false)
        {
            Contract.Requires(sender != null && sender is DependencyObject);

            var dobj = sender as DependencyObject;
            var type = dobj.GetType();

            // Look for the DependencyProperty attached to this property name
#if WINRT
            var pi = type.GetProperty(propertyName + "Property", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
            if (pi != null)
            {
                goto itWorks;
            }
#endif

            var fi = type.GetField(propertyName + "Property", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
            if (fi == null)
            {
                this.Log().Debug("Tried to bind DO {0}.{1}, but DP doesn't exist. Binding as POCO object",
                                 type.FullName, propertyName);
                var ret = new POCOObservableForProperty();
                return(ret.GetNotificationForProperty(sender, propertyName, beforeChanged));
            }

itWorks:
            return(Observable.Create <IObservedChange <object, object> >(subj => {
                DependencyProperty attachedProp;

                if (!attachedProperties.ContainsKey(type))
                {
                    // NB: There is no way to unregister an attached property,
                    // we just have to leak it. Luckily it's per-type, so it's
                    // not *that* bad.
                    attachedProp = DependencyProperty.RegisterAttached(
                        "ListenAttached" + propertyName + this.GetHashCode().ToString("{0:x}"),
                        typeof(object), type,
                        new PropertyMetadata(null, (o, e) => subjects[o].Item1.OnNext(o)));
                    attachedProperties[type] = attachedProp;
                }
                else
                {
                    attachedProp = attachedProperties[type];
                }

                // Here's the idea for this cracked-out code:
                //
                // The reason we're doing all of this is that we can only
                // create a single binding between a DependencyObject and its
                // attached property, yet we could have multiple people
                // interested in this property. We should only drop the actual
                // Binding once nobody is listening anymore.
                if (!subjects.ContainsKey(sender))
                {
                    var disposer = new RefcountDisposeWrapper(
                        Disposable.Create(() => {
#if !SILVERLIGHT && !WINRT
                        // XXX: Apparently it's simply impossible to unset a binding in SL :-/
                        BindingOperations.ClearBinding(dobj, attachedProp);
#endif
                        subjects.Remove(dobj);
                    }));

                    subjects[sender] = Tuple.Create(new Subject <object>(), disposer);

                    var b = new Binding()
                    {
                        Source = dobj, Path = new PropertyPath(propertyName)
                    };
                    BindingOperations.SetBinding(dobj, attachedProp, b);
                }
                else
                {
                    subjects[sender].Item2.AddRef();
                }

                var disp = subjects[sender].Item1
                           .Select(x => (IObservedChange <object, object>) new ObservedChange <object, object>()
                {
                    Sender = x, PropertyName = propertyName
                })
                           .Subscribe(subj);

                return Disposable.Create(() => {
                    disp.Dispose();
                    subjects[sender].Item2.Release();
                });
            }));
        }
Exemple #56
0
 static MainWindowVM()
 {
     MainDeckProperty = DependencyProperty.Register("MainCardDeck", typeof(CardDeck), typeof(MainWindowVM), new PropertyMetadata(new CardDeck(DeckSize)));
 }
Exemple #57
0
 static Adornment()
 {
     AdornedElementProperty = DependencyProperty.Register("AdornedElement", typeof(FrameworkElement), typeof(Adornment),
                                                          new FrameworkPropertyMetadata(null));
 }
Exemple #58
0
 public static void BindTo <T>(this FrameworkElement src, string srcProp, FrameworkElement dst, DependencyProperty dstProp,
                               Func <T, object> convert)
 {
     dst.SetBinding(dstProp, new Binding(srcProp)
     {
         Source = src,
         BindsDirectlyToSource = true,
         Converter             = new LambdaConverter <T>(convert)
     });
 }
Exemple #59
0
 static TreeViewItemProps()
 {
     ItemImageNameProperty = DependencyProperty.RegisterAttached("ItemImageName", typeof(string), typeof(TreeViewItemProps), new UIPropertyMetadata(string.Empty));
 }
Exemple #60
0
 /// <summary>
 /// Resolve the context to use for header/footer. This should be the Header/Footer properties if they are set;
 /// if not, but the HeaderTemplate/FooterTemplate is non-null, then the ListViewBase's DataContext should be used.
 /// </summary>
 private object ResolveHeaderOrFooterContext(DependencyProperty contextProperty, DependencyProperty templateProperty)
 {
     if (this.IsDependencyPropertySet(contextProperty))
     {
         return(GetValue(contextProperty));
     }
     else if (GetValue(templateProperty) != null)
     {
         return(DataContext);
     }
     else
     {
         return(null);
     }
 }