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

Set bindings for custom DependencyObjects

This is a continuation of a question here: Trying to setup a custom DependencyObject. Clearly missing something. It's not practical to edit the original question; changes are too great. So I'm starting a fresh question. I'm trying to setup bindings…
William Jockusch
  • 26,513
  • 49
  • 182
  • 323
0
votes
1 answer

Trying to setup a custom DependencyObject. Clearly missing something

I have the following in a UWP app. Notice that my Element descends from DependencyObject, not from a Control, Panel, etc. But when I call the test method MessWithBindings(), the bindings are not working. The PropertyChanged method does fire, but the…
William Jockusch
  • 26,513
  • 49
  • 182
  • 323
0
votes
1 answer

async method throw strange exception "most create DependencySource ..."

In my class have two methods async GetDataAsync and not sync GetData(). class Helper { public IList GetData(someargs) {} public Task> GetDataAsync(someargs) { return Task.Run(()=>Getdata(someargs) …
itihonov
  • 81
  • 1
  • 7
0
votes
1 answer

Add dependency property to a WPF behaviour

I have the following behavior that sets the color formatting of a GridControl which works fine if I set a static ColorScaleFormat. I however need to databind it to my view model as the colorscale format depends on the model data. Anyway to do so I…
rollsch
  • 2,518
  • 4
  • 39
  • 65
0
votes
1 answer

Get the UserControl of a Child control in Windows 10

I have a UserControl that consists of several child controls lets call it MyUserControl. So it contains a textbox among other controls as child. If I have the child textbox, how do I get MyUserControl as the parent and not just the Grid that textbox…
PutraKg
  • 2,226
  • 3
  • 31
  • 60
0
votes
1 answer

How to attach PreviewKeyDown event to Dependencyobject on instantiation?

I want to attach PreviewKeyDown event to my dependencyobject on instatiation. Code: public class PriceFieldExtension : DependencyObject { public static decimal GetPriceInputField(DependencyObject obj) { return…
Timsen
  • 4,066
  • 10
  • 59
  • 117
0
votes
1 answer

Binding on CollectionViewSource -> View -> Groups -> Count (Code vs XAML)

I'm trying to bind to a CollectionViewSource nested property (CVS.View.Groups.Count) and it doesn't seem to work in code : Binding binding = new Binding(); binding.Path = new PropertyPath("View.Groups.Count"); binding.Mode =…
tuxy42
  • 368
  • 3
  • 6
0
votes
1 answer

Multiple Dependency Properties

I'm currently working on a user control and stuck with the custom properties of the dependency object class IsEnabled gets recognized but not FooText XAML:
0
votes
1 answer

Keeping track of dependency property value changes at global level

I am having a number of controls in my application(which user can add to canvas), each having various properties(mostly dependency properties). User can change its properties through property grid(like color, text etc.). I have save functionality…
akjoshi
  • 15,374
  • 13
  • 103
  • 121
0
votes
1 answer

Using Linq methods causes missing references to DependencyObject in WindowsBase

I have some c# source that I want to compile using CodeDom within my application (for a plugin) Everything works fine, except if I use a Linq extension function on some of my collections var dict = new Dictionary
Jason Coyne
  • 6,509
  • 8
  • 40
  • 70
0
votes
0 answers

Change DependencyObject type to fix "Must be of type Visual3D." error?

I have a problem, I need to do that (a code to know X,Y,Z coordinates when I click on a Viewport3D that shows me a 3D image obtained with Kinect): bool success; Viewport3DVisual viewport3DVisual =…
0
votes
1 answer

Call bindings for DependencyObject when DependencyProperites are changed

Is there a way to notify a DependencyObject's bindinigs when the inner DependencyProperties have changed? For example, I have this class: public class BackgroundDef : DependencyObject { public static readonly DependencyProperty…
melculetz
  • 1,961
  • 8
  • 38
  • 51
0
votes
1 answer

Cannot convert type 'int' to 'bool'

I'm working on a custom login Textbox that has an Auto Complete function. However, When i try to: public static void SetSelectOnMouseOver(DependencyObject obj, bool value) { obj.SetValue(ListBoxItemBehavior.SelectOnMouseOverProperty, …
Enumy
  • 841
  • 2
  • 8
  • 20
0
votes
1 answer

WPF - Fill collection in an other thread

Im getting an error message when i try this: Task.Factory .StartNew(() => _model.GetItems(node).Select(n => n)) .ContinueWith(t => { if (t.Result != null) { ObservableCollection children = new…
0
votes
1 answer

DependencyObject that also implements INotifyPropertyChanged?

For a Silverlight and WPF app, I have a custom control that includes an ObservableCollection as a dependency property. One element of that control, a Border, needs to change color depending on the composition of items in the ObservableCollection. …
Jim O'Neil
  • 23,344
  • 7
  • 42
  • 67