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

WPF: Value inheritace for custom DependencyObjects?

I'm trying to implement value inheritance for a DependencyProperty in a custom WPF DependencyObject and I'm faling badly :( What I want to do: I have two classes T1 and T2 that have both a DependencyProperty IntTest, defaulting to 0. T1 should be…
Knasterbax
  • 7,895
  • 1
  • 29
  • 23
0
votes
2 answers

XAML Binding to a FrameworkElement in a UserControl

I got a custom UserControl (MyControl) with several properties (which works just fine). I want a new property that let the page using the UserControl "paste in" some content to be shown direct in the UserControl - ex. a Path. I have tried;…
Kim Rasmussen
  • 453
  • 1
  • 8
  • 21
0
votes
1 answer

Best practices for working with dependency objects outside of the UI thread

As the title suggests, I find myself in this situation a fair amount and believe I'm doing something wrong. Frequently I want a UI that is constantly updating based on the work of background tasks, but find that the separation between simply trying…
Cuthbert
  • 1,202
  • 1
  • 12
  • 18
0
votes
1 answer

Detect subproperty change in PropertyChangedCallback and get the subproperty

I am using DepdendencyObjects with PropertyChangedCallbacks and I want to detect a subproperty-change inside of this callback. The proplem is that the DependencyPropertyChangedEventArgs-Object does only let me see the Property that contains the DP…
HerpDerpington
  • 3,751
  • 4
  • 27
  • 43
0
votes
1 answer

DependencyObject in PropertyChangedCallback is not the same object

I'm seeing some strange behavior with my dependency properties. I set up the following property in my class MyControl. public static DependencyProperty MyTempProperty = DependencyProperty.Register("MyTemp", typeof(double), typeof(MyControl), …
NielW
  • 3,626
  • 1
  • 30
  • 38
0
votes
0 answers

In a DependencyObject subclass, can you override DependencyProperty?

For illustrative purposes, say I wanted to create a subclass of the WPF TextBox called BizarroTextBox where the IsReadOnly property has the reverse effect of its default behavior. Now normally in the non-WPF world, for a hypothetical 'TextBox'…
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
0
votes
1 answer

WPF Binding Confusion: Composite DependencyObject

I have a DependencyObject class composition that looks like the following: public class A : DependencyObject { public AB AB { get { ... } set { ... } } public AB AC { get { ... } set { ... } } } public class AB : DependencyObject { …
GEL
  • 162
  • 1
  • 11
0
votes
2 answers

Attached properties vs. custom control

I have often bemoaned the fact that the WPF ToggleButton does not have properties for AlternateContent and AlternateContentForeground. I'm curious if there's any advantage to creating a DependencyObject with attached properties, or deriving a…
0
votes
1 answer

Trying to create a recursive method to list Logical dependencies in hierarchical order

I used a VisualTree helper to get all the Visuals in my window but sometimes some certain controls are not listed in the returning list. That's because they are still not rendered, as far as I know, VisualTree enumeration will help only if the…
David von Tamar
  • 797
  • 3
  • 12
  • 29
0
votes
2 answers

How to update Target object from markup extension in SL5?

I'm trying this code in a markup extension in Silverlight 5. public override object ProvideValue(IServiceProvider serviceProvider) { _target = (IProvideValueTarget)serviceProvider.GetService(typeof(IProvideValueTarget)); _depObj…
1 2 3 4 5 6
7