Questions tagged [dependencyobject]

The DependencyObject class enables Windows Presentation Foundation (WPF) property system services on its many derived classes.

The property system's primary function is to compute the values of properties, and to provide system notification about values that have changed. Another key class that participates in the property system is DependencyProperty. DependencyProperty enables the registration of dependency properties into the property system, and provides identification and information about each dependency property, whereas DependencyObject as a base class enables objects to use the dependency properties.

DependencyObject services and characteristics include the following:

  • Dependency property hosting support. You register a dependency property by calling the Register method, and storing the method's return value as a public static field in your class.

  • Attached property hosting support. You register an attached property by calling the RegisterAttached method, and storing the method's return value as a public static read-only field in your class. (There are also additional member requirements; note that this represents a WPF specific implementation for attached properties. For details, see Attached Properties Overview.) Your attached property can then be set on any class that derives from DependencyObject.

  • Get, set, and clear utility methods for values of any dependency properties that exist on the DependencyObject.

  • Metadata, coerce value support, property changed notification, and override callbacks for dependency properties or attached properties. Also, the DependencyObject class facilitates the per-owner property metadata for a dependency property.

  • A common base class for classes derived from ContentElement, Freezable, or Visual. (UIElement, another base element class, has a class hierarchy that includes Visual.)

100 questions
0
votes
1 answer

Frustrating error in WPF (.NET 4.0) internals: Hashtable insert failed. Load factor too high

I have built custom Rules Engine, where each element of this engine is a descendant of DependencyObject class, so that it could be described in XAML including support for dependency properties, markup extensions, bindings, and so on. The purpose of…
Yuriy Magurdumov
  • 235
  • 2
  • 12
0
votes
2 answers

Can a class derived from DependencyObject marked as serializable?

What des it mean by the following sentence DependencyObjects are not marked as serializable To my knowledge, I can have a class which inherits from DependencyObject...and I can mark it as serializable. Anyway serialize property is not…
Relativity
  • 6,690
  • 22
  • 78
  • 128
0
votes
0 answers

When I encapulate a group of DependencyProperties into a DependencyObject, will property changes automatically be forwarded to UserControl?

I created a WPF UserControl with a number of DependencyProperty custom properties, which all affect OnMeasure and call PropertyChangedCallback, e.g.: private static readonly DependencyProperty ArrowStrokeThicknessProperty =…
AxD
  • 2,714
  • 3
  • 31
  • 53
0
votes
1 answer

Can we implement dependency property in a class that does not inherit from DependencyObject? If yes, what is the difference?

Can we implement dependency property in a class that does not inherit from DependencyObject? If yes what is the difference?
NovemberMan
  • 65
  • 1
  • 4
0
votes
0 answers

Trigger Dependency Property Changed when child Dependency Property has been changed

I have the following class: public class dm_fourvalues : DependencyObject { [JsonProperty] public double First { get { return (double)GetValue(FirstProperty); } set { SetValue(FirstProperty, value); …
l2rek
  • 32
  • 1
  • 5
0
votes
0 answers

WPF c# Inherited Dependency Object: how do you release instance events?

I am modifying the standard WPF Grid. On it I have several ObservableItemCollections that are dependency properties. These dependency properties have Property Changed Callbacks that set instance event handlers to the CollectionChanged and…
Lance
  • 251
  • 5
  • 13
0
votes
0 answers

MVS doesn't recognise SetValue() and GetValue()

So, I'm trying to make a wpf calendar, but I have problem with GetValue() and SetValue() methods. I have declared all of the libraries and it shows me that these methods doesn't exist at all and doesn't recognise them. using System; using…
0
votes
0 answers

Can you subclass a DependencyObject, changing a currently-read/write property into a read-only property in the subclass?

Title says it all. Not thinking this is possible due to the way DependencyProperties work, but figured I'd ask. Can you change a read-write property to a read-only property in a subclass?
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
0
votes
1 answer

Child object property change fires parents DependencyPropertyChanged callback?

In defining a base class inheriting an the Animatable, class, I have discovered what I am finding to be some odd behavior. When I create a Child DependencyProperty within a 'Parent' class, then define an instance of that 'Parent' class, then alter a…
Will
  • 3,413
  • 7
  • 50
  • 107
0
votes
1 answer

How to cast DependencyObject as FileInfo in PropertyChangedCallback

I have a FileInfo type DependencyProperty and in the PropertyChangedCallback, I can't cast the DependencyObject to FileInfo type. public static readonly DependencyProperty TargetFileProperty = DependencyProperty.Register("TargetFile",…
Still.Tony
  • 1,437
  • 12
  • 35
0
votes
1 answer

Binding Data Between Nested UserControls

I have a mainwindow that I spawn to start my application that drives a series of user controls. By default, the main window has one usercontrol inside. I'm having a challenge in propogating dependencyobjects from child usercontrols back up to a…
GregN
  • 142
  • 1
  • 13
0
votes
1 answer

ValidationRule and DependencyObject

I need to send Binding values to a ValidationRule. I am using a DependencyObject, but the values are always null. Here is my DependencyObject public class MyDependencyObject : DependencyObject { public string BindingValue { get {…
Xaphann
  • 3,195
  • 10
  • 42
  • 70
0
votes
1 answer

Getting a 'A 'Binding' can only be set on a DependencyProperty of a DependencyObject.' error on a DependencyObject

I keep getting a "A 'Binding' can only be set on a DependencyProperty of a DependencyObject." error in my XAML file and running the application isn't working either. I'm just going to post the code because I've been staring at this for hours, with…
RLH
  • 15,230
  • 22
  • 98
  • 182
0
votes
1 answer

trainings DependencyObject - custom command

I try to create Command which inherit from DependencyObject and ICommand. I have the following code: public class CustomCommand : DependencyObject, ICommand { public static readonly DependencyProperty CommandProperty; public static…
Cribanus
  • 3
  • 1