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
38
votes
5 answers

What is the difference between Property and Dependency Property

Dependency properties are created the same way as properties. Is a dependency property used only while creating a custom control?
None
37
votes
5 answers

When to use a WPF Dependency Property versus INotifyPropertyChanged

Do folks have any guidance on when a simple .NET property that fires INotifyPropertyChanged.PropertyChanged is sufficient in a view model? Then when do you want to move up to a full blown dependency property? Or are the DPs intended primarily for…
Keith Hill
  • 194,368
  • 42
  • 353
  • 369
34
votes
3 answers

Why do I get a DependencyProperty.UnsetValue when converting a value in a MultiBinding?

I have an extremely simple IMultiValueConverter that simply OR's two values. In the example below, I want to invert the first value using an equally simple boolean inverter.
Erik Kerber
  • 5,646
  • 7
  • 38
  • 56
28
votes
1 answer

WPF - Compilation error: Tags of type 'PropertyArrayStart' are not supported in template sections

Ordinarily I wouldn't just post an error message on SO, but after a Google search only found one hit, I thought I'd at least open the floor for this error here on SO. I have a custom control called Sparkline with a dependency property called Values…
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
27
votes
3 answers

ObservableCollection dependency property does not update when item in collection is deleted

I have a attached property of type ObservableCollection on a control. If I add or remove items from the collection, the ui does not update. However if I replace the collection within with a new one the ViewModel the ui does update. Can someone give…
GoalMaker
  • 905
  • 3
  • 9
  • 22
27
votes
3 answers

Wpf UserControl and MVVM

I am thinking about writing a WPF User Control for my application. I am using MVVM in my application. User control's may require Dependency Properties that can be set my Parent View. when using MVVM, the idea is that the Parent View will eventually…
byte
  • 1,665
  • 1
  • 19
  • 36
27
votes
1 answer

Binding to custom dependency property - again

The task: implement the simplest Dependency Property ever, which can be used in xaml like that: I think that this answer is quite close. For better readability i copy all my code here (mostly…
Martin Booka Weser
  • 3,192
  • 5
  • 28
  • 41
26
votes
2 answers

Dependency Property dependent on another

How can one register a dependency property whose value is calculated using the value of another dependency property? Because the .NET property wrappers are bypassed by WPF at run-time, one should not include logic in the getters and setters. The…
Gregyski
  • 1,707
  • 3
  • 18
  • 26
25
votes
2 answers

How to simply bind this to ConverterParameter?

I have problem and i don't know how to solve this simple, i have many points like this, then solution should be not complicated. I have main project with Settings and main XAML. I have dependency project with Binding Converter and XAML File looks…
Svisstack
  • 16,203
  • 6
  • 66
  • 100
25
votes
1 answer

How can I change the default value of an inherited dependency property?

How can I change the default value for an inherited dependency property? In our case, we've created a subclass of Control which by default has its Focusable set to 'true'. We want our subclass to have the default of 'false'. What we've been doing…
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
25
votes
5 answers

Quickly create dependency properties in VS

Is there any way to speed up creating dependency properties in Visual Studio? Like some template or refactoring option that will make dependency property out of normal one. Anything. I create a lot of dependency properties right now.
Rasto
  • 17,204
  • 47
  • 154
  • 245
24
votes
3 answers

Twoway-bind view's DependencyProperty to viewmodel's property?

Multiple sources on the net tells us that, in MVVM, communication/synchronization between views and viewmodels should happen through dependency properties. If I understand this correctly, a dependency property of the view should be bound to a…
l33t
  • 18,692
  • 16
  • 103
  • 180
23
votes
2 answers

Defining InputBindings within a Style

I'm creating a WPF app using the MVVM design pattern, and I'm trying to extend the TabItem control so that it closes the tab when the user clicks the middle mouse button. I'm trying to achieve this using InputBindings, and it works very well until I…
Brent
  • 1,743
  • 3
  • 16
  • 27
23
votes
1 answer

Custom Control Dependency Property Binding

I am going insane trying to get this to work with even the most basic example. I cannot for the life of me get binding to work. Here is a super easy example that is not working for me. I MUST be doing something incorrect. My Custom Control in my…
Jason Butera
  • 2,376
  • 3
  • 29
  • 46
22
votes
1 answer

How to use PropertyChangedCallBack

I have a TextBox Binded to a dependancy property, I have implemented a PropertyChangedCallBack function, when the text changes I need to call textbox.ScrollToEnd() but I cant since the PropertChanged function need to be static, is there a way around…
Eamonn McEvoy
  • 8,876
  • 14
  • 53
  • 83