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

Setting up binding to a custom DependencyProperty inside a WPF user control

I have a WPF UserControl containing a custom DependencyProperty named MyDP. I want to bind this to a property on my ViewModel (which is injected as the UserControl's DataContext). I know one way to do it by setting the binding in the UserControl's…
Tim Trout
  • 1,062
  • 12
  • 20
8
votes
3 answers

Design Time Data for Dependency Properties?

I am building a UserControl that has several DependencyProperties that I use for the bindings of the XAML of the control. When I work with MVVM I normally create a design time ViewModel, because I find that way it is easier to setup the layout of my…
Dzyann
  • 5,062
  • 11
  • 63
  • 95
8
votes
1 answer

Using enum as a dependency property in WPF

I try to use enum type as a dependency property in my custom control, but always get an error: public enum PriceCategories { First = 1, Second = 2, Third = 3, Fourth = 4, Fifth = 5, Sixth = 6 …
rem
  • 16,745
  • 37
  • 112
  • 180
8
votes
1 answer

WPF MVVM: INPC and mediating communication between view model & model

I've read various approaches to communicating changes in model data to the view model. Some suggest that the model should implement INotifyPropertyChanged where possible, so that it may notify the view model of changed properties. Some suggest a…
Drew R
  • 2,988
  • 3
  • 19
  • 27
8
votes
2 answers

Howcome the get/set in dependency property doesn't do anything?

I've created a dependency property like this: public partial class MyControl: UserControl { //... public static DependencyProperty XyzProperty = DependencyProperty.Register("Xyz",typeof (string),typeof (MyControl),new…
OscarRyz
  • 196,001
  • 113
  • 385
  • 569
8
votes
1 answer

Why Would a Dependency-Property Implementation Crash My Application When I Provide a Default Value?

Why would a dependency-property implementation crash my application when I provide a default value? This segment of code is in the class declaration for my UserControl object. Everything works fine - it compiles and runs perfectly. public static…
Giffyguy
  • 20,378
  • 34
  • 97
  • 168
8
votes
3 answers

wpf trouble using dependency properties in a UserControl

I made a UserControl that is meant to be updated once every few seconds with data from a serial port. This UserControl should be very simple, consisting of a Label for a field name, and another Label containing the field value. I say that it…
Klay
  • 1,971
  • 5
  • 26
  • 40
7
votes
2 answers

Dependency property List in UserControl

I have a dependency property(List of string) in a user control in my dot net assembly as below public partial class ItemSelectionUserControl : UserControl { public List AvailableItems { get { return…
Jimmy
  • 3,224
  • 5
  • 29
  • 47
7
votes
2 answers

How is dependency property implemented?

Can anyone explain how is dependency property implemented? Is it just a static dictionary that is declared in base class with a reference of given instance as a key?I can't find any resources about this in internet...Thanks a lot
Arsen Mkrtchyan
  • 49,896
  • 32
  • 148
  • 184
7
votes
2 answers

Custom Dependency Properties and TwoWay binding in WPF

We have an object that derives from DependencyObject, and implements some DependencyProperties. Basically something like this: class Context : DependencyObject { public static readonly DependencyProperty NameProperty = …
Matt Holmes
  • 1,055
  • 1
  • 8
  • 22
7
votes
2 answers

How do I clear the value set by SetCurrentValue in WPF?

For a DependencyProperty, I set a value using DependencyObject.SetCurrentValue(property, value). How does one unset the value so that the property evaluates to the normal local value again?
Kevin Hsu
  • 1,726
  • 11
  • 14
7
votes
3 answers

How do I programmatically read the value of an attached dependency property?

So I have a Button with an AutomationId (used by Microsoft UI Automation) like so:
7
votes
4 answers

How to inherit application.properties with spring boot multiple modules

I using spring boot multiple modules and i want inherit application.properties from parent . I have parent module : spring-ecommere-demo and sub module : model , core and security. In parent modules i put some config jdbc look like :…
BaoTrung Tran
  • 392
  • 2
  • 6
  • 21
7
votes
1 answer

What use is a DependencyProperty whose ownerType is not a DependencyObject?

I've just started playing with DependencyProperties in WPF and I was wanting to check a couple of thoughts while I get to grips with them. Given the following (and ignoring naming convention for now): class MyTestClass { public static readonly…
Matt__E_
  • 277
  • 2
  • 9
7
votes
4 answers

Creating a bindable Point in C# WPF

I know multiple inheritence is out, but is there a way to create a wrapper for System.Windows.Point that can inherit from it but still implement bindable dependency properties? I'm trying to code so that for my XAML I can create staments like the…
Ross Graeber
  • 179
  • 2
  • 10