Skip to main content

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-properties
Filter by
Sorted by
Tagged with
379 votes
14 answers
82k views

INotifyPropertyChanged vs. DependencyProperty in ViewModel

When implementing the ViewModel in a Model-View-ViewModel architecture WPF application there seem to be two major choices how to make it databindable. I have seen implementations that use ...
bitbonk's user avatar
  • 49.3k
143 votes
3 answers
64k views

What is a dependency property?

What is a dependency property in .Net (especially in WPF context). What is the difference from the regular property?
e11s's user avatar
  • 4,133
101 votes
5 answers
40k views

What's the difference between a dependency property and an attached property in WPF?

What's the difference between a (custom) dependency property and an attached property in WPF? What are the uses for each? How do the implementations typically differ?
kenwarner's user avatar
  • 29k
86 votes
6 answers
63k views

Listen to changes of dependency property

Is there any way to listen to changes of a DependencyProperty? I want to be notified and perform some actions when the value changes but I cannot use binding. It is a DependencyProperty of another ...
Rasto's user avatar
  • 17.6k
79 votes
2 answers
33k views

How do You Create a Read-Only Dependency Property?

How do you create a read-only dependancy property? What are the best-practices for doing so? Specifically, what's stumping me the most is the fact that there's no implementation of ...
Giffyguy's user avatar
  • 21.1k
72 votes
2 answers
23k views

Is there a way to specify a custom dependency property's default binding mode and update trigger?

I would like to make it so that, as default, when I bind to one of my dependency properties the binding mode is two-way and update-trigger is property changed. Is there a way to do this? Here is an ...
Justin's user avatar
  • 2,459
69 votes
7 answers
84k views

A 'Binding' can only be set on a DependencyProperty of a DependencyObject

From a custom control based on TextBox, I created a property named Items, in this way: public class NewTextBox : TextBox { public ItemCollection Items { get; set; } } When using the custom ...
mgottschild's user avatar
  • 1,105
63 votes
3 answers
52k views

What are the defaults for Binding.Mode=Default for WPF controls?

In WPF Binding.Mode, when selecting Default, it depends in the property being binded. I am looking for some list or some convention or any information for the defaults for the various controls. I ...
Shimmy Weitzhandler's user avatar
59 votes
4 answers
16k views

What's the difference between Dependency Property SetValue() & SetCurrentValue()

The reason why I am asking this is because I was recommended by @Greg D (from this question) to use SetCurrentValue() instead, but a look at the docs and didn't see whats the difference. Or whats does ...
Jiew Meng's user avatar
  • 86.5k
57 votes
9 answers
37k views

Error while removing project dependency in VS2010

I have a large solution with number of projects. Some the projects depend on others (never a circular dependency though). When I tried to remove a dependency of a project, I am getting an error ...
Aneesh Narayanan's user avatar
52 votes
9 answers
35k views

Hiding inherited members

I'm looking for some way to effectively hide inherited members. I have a library of classes which inherit from common base classes. Some of the more recent descendant classes inherit dependency ...
MojoFilter's user avatar
  • 12.2k
45 votes
2 answers
20k views

Setters not run on Dependency Properties?

Just a short question, to clarify some doubts. Are setters not run when an element is bound to a dependency property? public string TextContent { get { return (string)GetValue(TextContentProperty)...
Jiew Meng's user avatar
  • 86.5k
44 votes
4 answers
23k views

DependencyProperty.Register() or .RegisterAttached()

What's the difference between the two, when should RegisterAttached() be used instead of .Register()?
Sander Rijken's user avatar
42 votes
2 answers
16k views

Why dependency properties?

Why did Microsoft go the route of making dependency properties and dependency objects instead of using reflection and maybe attributes?
Mr Bell's user avatar
  • 9,338
39 votes
1 answer
24k views

How to use Attached property within a style?

I have created an Image within a ButtonStyle. Now I have created an Attached Property so that I can set the Source for that Image. Should be straight forward but I am stuck with it. This is my ...
Houman's user avatar
  • 65.6k
38 votes
5 answers
27k views

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?
user avatar
37 votes
5 answers
17k views

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 ...
Keith Hill's user avatar
  • 199k
35 votes
3 answers
43k views

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. <MultiBinding ...
Erik Kerber's user avatar
  • 5,656
28 votes
1 answer
5k views

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 ...
Drew Noakes's user avatar
28 votes
3 answers
40k views

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,...
byte's user avatar
  • 1,685
28 votes
1 answer
45k views

Binding to custom dependency property - again

The task: implement the simplest Dependency Property ever, which can be used in xaml like that: <uc:MyUserControl1 MyTextProperty="{Binding Text}"/> I think that this answer is quite ...
Martin Booka Weser's user avatar
27 votes
3 answers
19k views

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 ...
GoalMaker's user avatar
  • 905
26 votes
5 answers
24k views

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 ...
Rasto's user avatar
  • 17.6k
26 votes
1 answer
8k views

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 ...
Mark A. Donohoe's user avatar
26 votes
2 answers
40k views

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 ...
Svisstack's user avatar
  • 16.5k
26 votes
2 answers
11k views

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 ...
Gregyski's user avatar
  • 1,717
24 votes
7 answers
27k views

'{DependencyProperty.UnsetValue}' is not a valid value for property 'FocusVisualStyle'

I have a weird error I'm trying to debug with no luck. I have subclassed hwndhost showing some content, I have the following function in that class to set to fullscreen: private void ...
DaveO's user avatar
  • 1,959
24 votes
2 answers
15k views

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 ...
Brent's user avatar
  • 1,773
24 votes
3 answers
23k views

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 ...
l33t's user avatar
  • 19.7k
23 votes
2 answers
31k views

Binding to UserControl DependencyProperty

I have created a UserControl with some DependencyProperties (in the example here only one string property). When I instantiate the Usercontrol, I can set the property of the UserControl and it is ...
Lightbringer's user avatar
23 votes
1 answer
21k views

WPF ValidationRule with dependency property

Suppose you have a class inheriting from ValidationRule: public class MyValidationRule : ValidationRule { public string ValidationType { get; set; } public override ValidationResult ...
theSpyCry's user avatar
  • 12.2k
23 votes
1 answer
25k views

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 ...
Jason Butera's user avatar
  • 2,408
22 votes
2 answers
22k views

WPF usercontrol Twoway binding Dependency Property

I created a Dependency Property in the usercontrol, but however changes in the usercontrol was NOT notified to the Viewmodel Usercontrol <UserControl x:Class="DPsample.UserControl1" ...
Spen D's user avatar
  • 4,315
22 votes
2 answers
9k views

Why dependency properties in WPF has to be Static

Why a dependency property has to be Static? I have seen that it has been already asked in some post here, but I am not able to understand it properly. It will be great if someone can help me ...
Jasmine's user avatar
  • 5,286
22 votes
1 answer
28k views

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 ...
Eamonn McEvoy's user avatar
22 votes
4 answers
9k views

WPF override IsEnabled from Parent

I just searched for a way to enable a child control while the parent control has IsEnabled = false. All answers that I have found up to now say that it is not possible - one has to enable the parent ...
LionAM's user avatar
  • 1,361
20 votes
4 answers
9k views

What's the framework mechanism behind dependency properties?

I have been reading about dependency properties in several books but all have one thing in common, they just tell us how they are implemented( using static readonly DependencyProperty etc.) but does ...
Akshay J's user avatar
  • 5,408
20 votes
4 answers
29k views

What is a dependency property? What is its use? [duplicate]

Possiblity: What is a dependency property? What is a dependency property? How does it differ from a normal property? What is the purpose of dependency properties? And why it is used, when it is ...
Thiru G's user avatar
  • 620
20 votes
4 answers
11k views

Maven: Import pom properties from different pom

I would like to import properties from a project X pom file into my project Y pom such as library versions. I do not want to make the project X my project's parent. I have tried to include project ...
user518066's user avatar
  • 1,327
19 votes
2 answers
50k views

How to bind to a WPF dependency property when the datacontext of the page is used for other bindings?

How to bind to a WPF dependency property when the datacontext of the page is used for other bindings? (Simple question)
Thomas Bratt's user avatar
  • 50.3k
19 votes
3 answers
7k views

Getting "<Property Name> was already registered by "<Control Name>" error in WPF

I have a user control in WPF that has a binding to a Dependency Property. When I try to compile the app, I get a "Property Name" was already registered by "ControlName" error, and the designer shows a ...
Ryan's user avatar
  • 1,330
19 votes
5 answers
21k views

How to debug DependencyProperty.Unsetvalue errors when the InnerException is null

I have a custom login usercontrol that has a normal textbox and a passwordbox. Blend refuses to cooperate with the PasswordBox saying that "DP.UnsetValue" is not valid for PasswordChar property. ...
TWood's user avatar
  • 2,583
19 votes
5 answers
29k views

Binding UserControl Dependency Property and MVVM

I have a MainWindow containing a UserControl, both implemented in MVVM-pattern. The MainWindowVM has properties that I want to bind to properties in the UserControl1VM. But this doesn't work. Here's ...
joerg's user avatar
  • 747
19 votes
1 answer
6k views

C# WPF Attached Properties - Error: "The property does not exist in XML namespace"

I need to create a new property to existing WPF controls (Groupbox, textbox, checkbox, etc), one that will storage its acess Level, therefore I've found out Attached Properties. I used as example this ...
Luishg's user avatar
  • 787
18 votes
1 answer
11k views

How to subscribe to change DependencyProperty? [duplicate]

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 ...
Kovpaev Alexey's user avatar
18 votes
2 answers
21k views

Listen to DependencyProperty changed event and get the old value

I have the following code to subscribe to property changed event for VisiblePosition property of Column class: DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(ColumnBase....
sean717's user avatar
  • 12.3k
18 votes
2 answers
6k views

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 ...
RoelF's user avatar
  • 7,533
17 votes
7 answers
1k views

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 ...
Sandbox's user avatar
  • 8,098
17 votes
3 answers
12k views

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 ...
Temitayo's user avatar
  • 802
17 votes
5 answers
6k views

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 - ...
Andrey's user avatar
  • 21k

1
2 3 4 5
47