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

Custom WPF binding not being updated on listbox selection

I'm puzzled by this probably trivial matter. I have my custom property on a descendant of DevExpresses class LayoutGroup (shouldn't make any difference IMO): public class ExpandableLayoutGroup : LayoutGroup { public static readonly…
SmartK8
  • 2,616
  • 1
  • 29
  • 37
2
votes
1 answer

Adding a DependencyProperty to a class that extends ObservableCollection

I have a class called ObservableCollectionWithValidState that serves to notify itself when an of it's child objects break a validation rule. Class: child child <== violated a passed in Predicate and is now invalid. child When this happens I would…
2
votes
1 answer

Custom IValueConverter inheriting from DependencyObject

I wanted to experiment with being able to have a converter whose arguments can be bound with the current data context. Can anyone tell me why when reaching the Convert() function, the Source property is always null? namespace WpfApplication32 { …
hammer
  • 145
  • 1
  • 10
2
votes
1 answer

DependencyObject's binding context

I'm trying to understand the low-level details of the Silverlight dependency property system. I realize that DependencyObject has no explicit DataContext property or even the notion of a parent. The Behavior class however, which derives from…
John
  • 6,693
  • 3
  • 51
  • 90
1
vote
3 answers

Binding in Converter?

I'm trying to make a custom converter that inherits from DependencyObject, but it doesn't work: Converter: public class BindingConverter : DependencyObject , IValueConverter { public object Value { get { return…
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
1
vote
2 answers

Filter DependencyObject and DependencyProperties from a DLL/Assembly?

I got the following code to generate a DLL : public class QtObject : DependencyObject { public int speedSimu { get { return (int)GetValue(speedSimuProperty); } set { SetValue(speedSimuProperty, value); } } public…
Guillaume Slashy
  • 3,554
  • 8
  • 43
  • 68
1
vote
1 answer

UWP DependencyObject Binding Windows.UI.Xaml.Markup.XamlParseException

I have a Visual Studio 2019 UWP project with a XAML page using dependency properties for binding values. It's all working fine in debug mode but not in release. What's wrong with the way I am binding that VS relase doesn't like? The sample code…
Gregory Bologna
  • 270
  • 1
  • 6
  • 20
1
vote
1 answer

WPF DependencyProperty: how to specify the OPPOSITE action of PropertyChangedCallback?

I'm adding a custom string DependencyProperty to a WPF UserControl that will be bound to a string property in my business object that contains rtf. My PropertyChangedCallback works: it contains a snippet of code to use the e.NewValue rtf string to…
1
vote
1 answer

Better way to trigger color change based on displayed text

I have a struct class that records a value and a check, which simply says whether it is good or bad. public enum StressCheck { Good, Bad } public struct Stress { public Stress(double stressValue,…
moostang
  • 73
  • 7
1
vote
1 answer

Why is this Animatable property being set again?

Follow up to this question. Apparently, for some reason after having explicitly set the Parent.Child property ( either inside the constructor or explicitly outside of the constructor ), when I set the Child.Trigger property of the Parent.Child…
Will
  • 3,413
  • 7
  • 50
  • 107
1
vote
0 answers

Binding in WPF and Silverlight - how does it actually work?

How does binding work under the hood in WPF and Silverlight? I have implemented INotifyPropertyChanged on my ViewModel objects and also used dependency properties on UI controls. Now, I am aware of the fact that the binding system will subscribe to…
Sandbox
  • 7,910
  • 11
  • 53
  • 67
1
vote
2 answers

Bind to DependencyProperty in code

I have an object which is derived from DependencyObject with multiple DependencyProperties. This object is a given and I can not add ValueChanged callbacks within this object. I would like to be notified (in code, not xaml) of any property changes.…
Wouter
  • 2,170
  • 1
  • 28
  • 58
1
vote
2 answers

UWP LogicalTreeViewHelper

I'm trying to convert an library from wpf to uwp. I'm almost done but now there is the LogicalTreeViewHelper which doesn't exist in UWP anymore. does anyone know how to replace it in uwp? var parent =…
Tobias Koller
  • 2,116
  • 4
  • 26
  • 46
1
vote
1 answer

How to get property name from the sender object of an INotifyPropertyChanged PropertyChanged event

I have a base DependencyObject class where I have a method that takes an object, gets the properties, and for each property that is a type that implements INotifyPropertyChanged, I add a new PropertyChangedEventHandler. Now in the handler method, it…
1
vote
1 answer

DependencyObject.SetValue vs cast and set property

I have a property changed callback and in it i need to perform some validation. I am going to take a new value and validate it against a set of other property criteria such as min and max values. To do this I am planning to either take the…
LiamHarries
  • 570
  • 1
  • 5
  • 20