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
9
votes
2 answers

TemplateBinding not working for textbox text

I have a custom control called EnhancedTextBox which is a UserControl that has a TextBox and a Button. To the consumer I want it to mostly look like a TextBox, so I did the following:
Justin Pihony
  • 66,056
  • 18
  • 147
  • 180
9
votes
2 answers

UserControl Dependency Property design time

I'm creating a simple User Control in WPF that contains a TextBlock inside a Button.
Guilherme
  • 5,143
  • 5
  • 39
  • 60
8
votes
3 answers

WPF Dependency Properties: Why do I need to specify an Owner Type?

This is how I register a DependencyProperty: public static readonly DependencyProperty UserProperty = DependencyProperty.Register("User", typeof (User), typeof (NewOnlineUserNotifier)); …
Andreas Grech
  • 105,982
  • 98
  • 297
  • 360
8
votes
1 answer

Add dependency property to control

I am using the Infragistics XamDateTimeEditor control and I want to add a dependency property to it to allow the developer to choose to have all the text selected when the control gets focus. I have created a style that is used to set the behavior…
user31673
  • 13,245
  • 12
  • 58
  • 96
8
votes
1 answer

WebBrowser in WPF using MVVM pattern

I am trying to open HTML file in WebBrowser window of WPF using MVVM patten. Note: I have fixed the issues i was getting. Now this code works as desired. ViewHTMLPageView.xaml
Shai
  • 529
  • 7
  • 20
  • 36
8
votes
2 answers

Customizing The DependencyObject Inheritance Tree

I'm struggling to find sufficient information about the property Inheritance Tree (or Inheritence Context) used by DependencyObject and DependencyProperty. I would like to use the value inheritence capability of DependencyProperty outside of a…
Mark
  • 9,320
  • 6
  • 57
  • 70
8
votes
2 answers

What is a Dependency Property and when is it used?

Possible Duplicate: What is a dependency property? I have been browsing through the net to find the definition of a dependency prop, but cannot find the simplest def for this. Can anyone help me with an example?
Donald N. Mafa
  • 5,131
  • 10
  • 39
  • 56
8
votes
1 answer

Why can I access DependencyProperties that are not registered on my DependencyObject?

I'm hoping someone can explain some unexpected behaviour I have come across whilst continuing my exploration of DependencyObjects and DependencyProperties. Given the following simple class: class SomeClass : DependencyObject { } I can…
Matt__E_
  • 277
  • 2
  • 9
8
votes
3 answers

Why after animating height setting this property directly stops working

I have problem which is killing me. Below is simple example
8
votes
4 answers

why don't people wrap DependencyProperties in a generic class?

I didn't like how verbose dp's are, since most of the code is just repeated, I just wrapped it in a generic class. Having seen quite allot of sample code, I was wondering why more people aren't doing the same. I haven't come across any problems to…
Dead.Rabit
  • 1,965
  • 1
  • 28
  • 46
8
votes
2 answers

XML Documentation for dependency properties

What is the best way to document a dependency property? Should I put the xml documentation on the field: /// Documentation goes here public static readonly DependencyProperty NameProperty = …
Stefan
  • 4,187
  • 1
  • 32
  • 38
8
votes
1 answer

WPF Custom Control: DependencyProperty never Set (on only 1 of many properties)

I have made a custom control called AddressForm, which inherits from Control. The control is used to display the fields for an IAddress object. Originally I made this control in Silverlight, now I am trying to get it working in WPF .net 4.5 The…
Shaboboo
  • 1,347
  • 1
  • 16
  • 35
8
votes
1 answer

DependencyProperty ValidateValueCallback question

I added a ValidateValueCallback to a DependencyProperty called A. Now in the validate callback, A shall be compared to the value of a DependencyProperty called B. But how to access the value of B in the static ValidateValueCallback method…
stefan.at.kotlin
  • 15,347
  • 38
  • 147
  • 270
8
votes
3 answers

Change binding value, not binding itself

I've got a WPF UserControl containing a DependencyProperty (MyProperty). The DependencyProperty is bound to a Property in the DataContext. Now in the UserControl I want to change the value of the bound property. But if I assign MyProperty = NewValue…
Sam
  • 28,421
  • 49
  • 167
  • 247
8
votes
1 answer

How can I bind another DependencyProperty to the IsChecked Property of a CheckBox?

Here's an example of what I'm trying to accomplish:
Eben Geer
  • 3,696
  • 3
  • 31
  • 34