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
17
votes
1 answer

How to subscribe to change DependencyProperty?

Possible Duplicate: Listen to changes of dependency property Excuse me for my English. I need to create a class that could subscribe to change DependencyProperty, and depending on the new value of this property to perform some action. Like…
Kovpaev Alexey
  • 1,725
  • 6
  • 19
  • 38
17
votes
2 answers

DependencyProperty doesn't fire ValueChanged when new value is the same

Ok so here's the problem: I wrote a UserControl which receives a new value say like every 100ms and does something with it. It has to handle each new value setter, even if the value didn't change. The UserControl has a few…
RoelF
  • 7,483
  • 5
  • 44
  • 67
17
votes
7 answers

Demystifying Dependency Properties

I have read about dependency properties a lot on SO and other sites. But, really haven't found a great explanation and am still confused. I use both SL and WPF. Are they different in SL and WPF, in terms of implementation? Why do we really need…
Sandbox
  • 7,910
  • 11
  • 53
  • 67
17
votes
5 answers

Need a short and clear definition for "Dependency Properties"

I'm trying to figure out what exactly Dependency Properties are, but when I look anywhere for a definition, I only find "how to use" but not "what it is". Imagine you are asked on a job interview - what is a dependency property. What would be your…
Andrey
  • 20,487
  • 26
  • 108
  • 176
17
votes
3 answers

Binding a PyQT/PySide widget to a local variable in Python

I'm pretty new to PySide/PyQt, I'm coming from C#/WPF. I've googled alot on this topic but it no good answer seems to show up. Ii want to ask is there a way where I can bind/connect a QWidget to a local variable, whereby each object update…
Temitayo
  • 802
  • 2
  • 12
  • 28
15
votes
1 answer

Limit attached dependency property in wpf

I want to attach a dependency property to specific controls only. If that is just one type, I can do this: public static readonly DependencyProperty MyPropertyProperty = DependencyProperty.RegisterAttached("MyProperty", typeof(object),…
ordag
  • 2,497
  • 5
  • 26
  • 35
15
votes
3 answers

Why does my data binding see the real value instead of the coerced value?

I'm writing a real NumericUpDown/Spinner control as an exercise to learn custom control authoring. I've got most of the behavior that I'm looking for, including appropriate coercion. One of my tests has revealed a flaw, however. My control has 3…
Greg D
  • 43,259
  • 14
  • 84
  • 117
15
votes
2 answers

Why are dependency properties "static"?

Could someone please explain why dependency properties are declared as static ?
Kishore Kumar
  • 21,449
  • 13
  • 81
  • 113
15
votes
4 answers

WPF User Control hell with MVVM and Dependency Properties

This is what I'm trying to do: I'm writing a UserControl that I want to be consumed by other developers. I want end users to be able to use my control using Dependency Properties.
Jon Mitchell
  • 3,349
  • 5
  • 27
  • 37
15
votes
1 answer

dependency property - member not recognised or not accessible

I have created a UserControl and inside it defined a dependency property Label. When I refer it in a control I get the error the The member "Label" is not recognised or is not accessible. What I don't understand is that it works perfect on windows…
14
votes
1 answer

DependencyProperty from string

How do I convert a property name (in string) to a DependencyProperty? I have a set of property names, its values in string and a DependencyObject. Now I want to set these property values to the DependencyObject. Any idea on how this can be…
sudarsanyes
  • 3,156
  • 8
  • 42
  • 52
14
votes
5 answers

How to enumerate all dependency properties of control?

I have some WPF control. For example, TextBox. How to enumerate all dependency properties of that control (like XAML editor does)?
Dennis
  • 37,026
  • 10
  • 82
  • 150
14
votes
1 answer

Dependency Property is not updating my Usercontrol

The line below works for the TextBox DP Text, where CellNo is a property of a class which derives from INotifyPropertychanged. So here when I change the CellNo the Text will be updated and When I change the CellNo the Text will be updated. This will…
Ashish Ashu
  • 14,169
  • 37
  • 86
  • 117
14
votes
6 answers

When to use Dependency Properties

I sometimes think I maybe using Dependency Properties unnecessarily. When do I need to use it? When I have a property that dependes on other properties? Say I have a Color property that I want it to be dependent on properties Hue, Saturation,…
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805
14
votes
1 answer

Multiple user controls share collection dependency property

I have implemented my own usercontrol based on listboxes. It has a dependency property with type of a collection. It works fine when I have only one instance of the usercontrol in a window, but if I have multiple instances I get problem that they…
Wallstreet Programmer
  • 9,567
  • 3
  • 37
  • 52