Questions tagged [dependencyobject]

The DependencyObject class enables Windows Presentation Foundation (WPF) property system services on its many derived classes.

The property system's primary function is to compute the values of properties, and to provide system notification about values that have changed. Another key class that participates in the property system is DependencyProperty. DependencyProperty enables the registration of dependency properties into the property system, and provides identification and information about each dependency property, whereas DependencyObject as a base class enables objects to use the dependency properties.

DependencyObject services and characteristics include the following:

  • Dependency property hosting support. You register a dependency property by calling the Register method, and storing the method's return value as a public static field in your class.

  • Attached property hosting support. You register an attached property by calling the RegisterAttached method, and storing the method's return value as a public static read-only field in your class. (There are also additional member requirements; note that this represents a WPF specific implementation for attached properties. For details, see Attached Properties Overview.) Your attached property can then be set on any class that derives from DependencyObject.

  • Get, set, and clear utility methods for values of any dependency properties that exist on the DependencyObject.

  • Metadata, coerce value support, property changed notification, and override callbacks for dependency properties or attached properties. Also, the DependencyObject class facilitates the per-owner property metadata for a dependency property.

  • A common base class for classes derived from ContentElement, Freezable, or Visual. (UIElement, another base element class, has a class hierarchy that includes Visual.)

100 questions
1
vote
1 answer

Dependency Property not set from style

I'm trying to synchronize scrolling between two datagrids so that each scroll is mirrored between them (either horizontal or vertical scrolling), after googling around how to do I started to implement my method but the setter call from my scrollbar…
Stephen Ross
  • 882
  • 6
  • 21
1
vote
2 answers

Specify Binding of DependencyProperty in UserControl itself

Following up on my previous question (Change brushes based on ViewModel property) In my UserControl I have have a DependencyObject. I want to bind that object to a property of my ViewModel. In this case a CarViewModel, property name is Status and…
RvdK
  • 19,580
  • 4
  • 64
  • 107
1
vote
1 answer

What is the DataContext of a DependencyObject in Silverlight4?

I have read that SL4 introduces the ability to data bind properties on objects that derive from DependencyObjects, where previously data-binding only worked on FrameworkElements or FrameworkContentElements. However, I am not clear on how the binding…
mackenir
  • 10,801
  • 16
  • 68
  • 100
1
vote
1 answer

Set Padding only on elements that implement the Padding property

I am working with the classes in the System.Windows.Documents namespace, trying to write some generic code that will conditionally set the value of certain dependency properties, depending on whether these properties exist on a given class. For…
Tim Coulter
  • 8,705
  • 11
  • 64
  • 95
1
vote
2 answers

How WPF DependencyProperty pickup the key to distinguish each instance of an object and seek the values of the DependencyProperty?

From google, a lot of articles said that DependencyProperty is static because it has a KeyValue mechanism to maintain the value of each instance of the object. But the problem is that, if we call GetValue / SetValue against the DependencyProperty,…
mind1n
  • 1,196
  • 3
  • 15
  • 34
1
vote
1 answer

Set value of DependencyProperty and preserve OneWayToSource-Binding

If I have a DependencyObject with a OneWayToSource Binding set on one property and then try to set the DP's value again, the Binding is being removed. I can not use the 'reversed' way with a direct (normal) Binding, so I have to use a OneWayToSource…
HerpDerpington
  • 3,751
  • 4
  • 27
  • 43
1
vote
1 answer

Is it wrong/bad to use INPC on a DependencyObject to support built-in conversion behavior?

We have a DependencyObject which defines a Value property as a DP. It also defines a Presets collection representing friendly names for some pre-defined values. The way our UI should work is when we bind to the Value property, if the value matches a…
1
vote
1 answer

WPF+MVVM: How to use plain old ViewModelBase when DependencyProperty is needed

I am using a 3rd party WPF control whose MVVM support relies on dependency properties on the VM it is bound to. The sample that comes with the control uses a ViewModelBase class derived from DependencyObject so all is well. My ViewModelBase…
Charlie
  • 764
  • 2
  • 13
  • 24
1
vote
4 answers

WPF DependencyProperty Validation Binding to the object property

I am trying to create a validation rule for a given control (in this scenario, it is the TextBox). I am not able to obtain a successful Binding to the property of an object, although appropriate steps were taken: ValidationRule and…
EARNEST
  • 107
  • 4
  • 11
1
vote
3 answers

VisualTreeHelper not finding children of DependencyObject, How can I reliably find objects?

I have a UserControl called ZoneContainer. This has a property that which contains a ListBox containing a number of ListItems. Each ListItem contains a DockPanel. I'm trying to use a the following code to find the children that exist inside…
DaveDev
  • 41,155
  • 72
  • 223
  • 385
1
vote
1 answer

Understanding dependency property system

Could someone help me to figure out with dependency property system in WPF?! I just wanted to do something like this: Assume, class A have a property (DP) called "A_property". Another class B just represent some business logic and I wanted this…
Alexander Knoth
  • 137
  • 1
  • 13
1
vote
3 answers

using the objects which are created by other thread

I just want to change the window's background in another thread. there are two program, one is work right, and the other throw an InvalidOperationException. The right code: public partial class MainWindow : Window { public MainWindow() { …
adream307
  • 95
  • 1
  • 7
0
votes
1 answer

Image source doesnt change according to the dependencyObject

i'm trying to style my image according to dependancy object i defined as followed: in MainWindow.xaml:
kaycee
  • 1,199
  • 4
  • 24
  • 42
0
votes
2 answers

UWP "form" validation event

I have a StackPanel of basic input controls. Some combinations selections are invalid. I would like to recompute the "form"s validation every time one of the inputs change. Is there some kind of event you can listen to on the parent control that…
Tom Huntington
  • 2,260
  • 10
  • 20
0
votes
1 answer

PropertyChangedCallback not triggered when DependencyObject Class Member is Modified

I created a DependencyObject with properties in it, I also have it inherit INotifyPropertyChanged. But when it is implemented as a DependencyProperty, it does not trigger PropertyChangedCallback when I change a single property from the…