Questions tagged [dependency-properties]

A property in WPF and Silverlight that can be set through methods such as, styling, data binding, animation, and inheritance.

Dependency property is a property backed by a static DependencyProperty instance.

The purpose of dependency properties is to provide a way to compute the value of a property based on the value of other inputs and to provide notification when computed value changes. The priority of inputs which contribute to computation is listed in Dependency Property value precedence overview.

Dependency properties usually have CLR "wrappers": the actual get and set implementations for the property.

Dependency property declaration (static field + wrapper) is a boilerplate code, which follows a certain pattern and can be generated by IDE (check Visual Studio shortcuts here).

General information: Dependency Property Overview

2294 questions
11
votes
2 answers

Order that DependencyProperties bindings are evaluated?

What determines the order that multiple DepdencyProperties on the same control get evaluated in? I am using the Extended WPF Toolkit PropertyGrid and have both SelectedObject and PropertyDefinitions bound:
BrandonAGr
  • 5,827
  • 5
  • 47
  • 72
11
votes
2 answers

Determine if a WPF DependencyProperty value is inherited

Does anyone know how to determine if the value of a WPF property is inherited? In particular, I'm trying to determine if the DataContext of a FrameworkElement was inherited from the parent or set directly on the element itself.
Michael Hewitt
  • 275
  • 1
  • 2
  • 8
11
votes
3 answers

How do I make Binding respect DependencyProperty value coercion?

I have a control with a DependencyProperty with a CoerceValueCallback. This property is bound to a property on a model object. When setting the control property to a value that causes coercion the Binding pushes the uncoerced value to the model…
Jesper Larsen-Ledet
  • 6,625
  • 3
  • 30
  • 42
11
votes
2 answers

Does Binding work ONLY with DependencyProperty?

MSDN says, Each binding typically has these four components: a binding target object, a target property, a binding source, and a Path to the value in the binding source to use. For example, if you want to bind the content of a TextBox to…
Nawaz
  • 353,942
  • 115
  • 666
  • 851
11
votes
3 answers

Displaying FontFamily in Combobox

My goal is to manipulate the text-styles of my application via DependencyProperties. I got a diagram in which the texts are to be manipulated in size, fontfamily, color, etc. So I'd like to use an interface similar to a rich text editor like…
Torsten
  • 1,696
  • 2
  • 21
  • 42
11
votes
3 answers

Getting 'this' pointer inside dependency property changed callback

I have the following dependency property inside a class: class FooHolder { public static DependencyProperty CurrentFooProperty = DependencyProperty.Register( "CurrentFoo", typeof(Foo), typeof(FooHandler), new…
Mizipzor
  • 51,151
  • 22
  • 97
  • 138
11
votes
2 answers

How to get a DependencyProperty by name in Silverlight?

Situation: I have a string that represents the name of a DependencyProperty of a TextBox in Silverlight. For example: "TextProperty". I need to get a reference to the actual TextProperty of the TextBox, which is a DependencyProperty. Question: how…
JeroenNL
  • 203
  • 2
  • 9
11
votes
3 answers

DepedencyProperty within a MarkupExtension

Is it possible to have a DependencyProperty within a MarkupExtension derived class? public class GeometryQueryExtension : MarkupExtension { public XmlDataProvider Source { get; set; } public string XPath { get; set; } public static…
Andrew Keith
  • 7,515
  • 1
  • 25
  • 41
11
votes
1 answer

Force Propagation of Coerced Value

tl;dr: Coerced values are not propagated across data bindings. How can I force the update across the data binding when code-behind doesn't know the other side of the binding? I'm using a CoerceValueCallback on a WPF dependency property and I'm…
O. R. Mapper
  • 20,083
  • 9
  • 69
  • 114
10
votes
3 answers

In WPF do DependencyProperty's cause lots of boxing/unboxing when used with value types?

In WPF do DependencyProperty's cause lots of boxing/unboxing when used with value types? Or does the implementation some how to prevent this and not box/unbox value types? Is so how do they do this? I think value types are a major use case for…
JamesRedcoat
  • 2,083
  • 2
  • 15
  • 13
10
votes
1 answer

DependencyProperty Default Value

I'm trying to get a DependencyProperty working in WPF. I'm using: public static readonly DependencyProperty DisplayModeProperty = DependencyProperty.Register("DisplayMode", typeof (TescoFoodSummary), typeof (Orientation), new…
Echilon
  • 10,064
  • 33
  • 131
  • 217
10
votes
4 answers

WPF: PropertyChangedCallback triggered only once

I have a user control, which exposes a DependencyProperty called VisibileItems Every time that property gets updated, i need to trigger another event. To achieve that, i added a FrameworkPropertyMetadata with PropertyChangedCallback event. For…
Sonic Soul
  • 23,855
  • 37
  • 130
  • 196
10
votes
1 answer

WPF Custom Control - How do you unit test a custom control?

Basically, I'm looking for resources/guides on how to unit test a WPF Custom Control. In this particular instance, the custom control I created happens to extend the Decorator class. It wraps a PasswordBox child to expose the CLR Password Property…
myermian
  • 31,823
  • 24
  • 123
  • 215
10
votes
6 answers

Missing snippet in Visual Studio

I have the same installation of Visual Studio on two machines, but on one, I can't find the snippet "propdp" for DependencyProperty. I only have prop/propg, can't really understand why. Is there an addon I have to install?
syncis
  • 1,395
  • 4
  • 25
  • 43
10
votes
0 answers

DependencyProperty Value Inheritance equivalent in UWP

Given a Visual Tree in WPF, it is possible to specify that AttachedProperties are inherited as follows: public static class MyClass { public static readonly DependencyProperty FooProperty = DependencyProperty.RegisterAttached( …
Dr. Andrew Burnett-Thompson
  • 20,980
  • 8
  • 88
  • 178