dependency-properties

Hiding inherited members in C#

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 properties which have become vestigial and can be a little confusing when using intellisense or using the classes in a visual designer. These ...

In silverlight, how to you attach a changeEvent handler to an inherited dependency property?

How would you attach a propertychanged callback to a property that is inherited? Like such: class A { DependencyProperty prop; } class B : A { //... prop.AddListener(PropertyChangeCallback); } ...

Where do attached properties fit in a class diagram?

What is the most appropriate way to represent attached properties in a UML diagram or an almost-uml diagram like the VS2008 class diagram? ...

Any way to un-register a WPF dependency property?

I'm running into an unusual problem in my unit tests. The class I'm testing creates a dependency property dynamically at runtime and the type of that dependency property can vary depending on the circumstances. While writing my unit tests, I need to create the dependency property with different types and that leads to errors because you ...

Setting WPF dependency property without triggering events

Hi, I need to set a dependency property on a control (Slider.Value) in my code without it triggering a ValueChanged event (since I set the value, not the user). What is the best way to handle this situation in WPF? For clarification, what I am trying to do is hook up WPF sliders to a WinForms User Control. Currently in my app I have a ...

Is Validation called before or after Coercion when setting a DependencyProperty value?

I created a simple class with a DependencyProperty. When setting the value, I observe that ValidateValueCallback is called before CoerceValueCallback. On wpftutorial and in other books, it is stated that coercion is called before validation. ...

Is it acceptable to "borrow" dependency properties from unrelated classes?

I'm writing a class that renders some content in WPF, and I want to give the user control over how the content is rendered. The rendering is mostly stroking lines, so I decided to look to the System.Windows.Forms.Shapes.Line class to get an idea of what properties I might want to implement. This led me to implement most of the StrokeXX...

Is there a notification mechanism for when a dependency property has changed?

In a Silverlight application I'm trying to find out when a property on a usercontrol has changed. I'm interested in one particular DependencyProperty, but unfortunately the control itself doesn't implement INotifyPropertyChanged. Is there any other way of determining if the value has changed? ...

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 DependencyProperty for properties the View is going to bind against and I have seen the ViewModel implementing INotifyPropertyChanged instead. My quest...

WPF DependencyProperties

Hi, I have just realized I've been coercing binding/dependency properties and not really fundamentally understanding the concept. Heres the dependency property: public string Problem { get { return (string)GetValue(ProblemProperty); } set { SetValue(ProblemProperty, value); } } public static readonly DependencyProperty Proble...

WPF Template Binding in ToggleButton UserControl

I'm developing a basic dip-switch user control as a personal learning exercise. Originally I had it set up where you could declare some custom color properties on the user control, and they would be used on elements inside the control. However, I recenly discovered ToggleButtons, and rebuilt my control to take advantage of them. Since t...

Dependency Properties with Explicit Interfaces

Hi all, I am knocking together a WPF demo for our department at work to show them the advantages of WPF whilst trying to adhere to our development standards (dependency injection and developing objects to an explicit interface). I have come to a bit of a wall now. I am implementing the View using the MVVM design pattern and I need to u...

Exposing an ImageSource property in a UserControl for use in Blend

I have a user control that exposes a property of type ImageSource. I want to expose this property in Blend so that I can edit it in Blend, rather than specifying the image in code. Based on what I've Googled, I've added a dependency property, and specified appropriate attributes to expose the property in Blend. I can see it there, and...

WPF User Control

I want to have a User Control that takes a collection of People (property "Data") and displays them in a list box. When I run my app nothing shows in the listbox. Can you please point out what I'm doing wrong? Thanks!!! public class Person { public string Name { get; set; } public int Age { get; set; } public override string...

Who has the best metaphor for WPF dependency properties?

I'm reading WPF Recipes in C# 2008: http://www.apress.com/book/view/9781430210849 and starting on the third recipe they asssume you know how dependency properties work. So after a little googling, I understand in general that these are properties of an object which when placed inside another object "adapts to the context" to the host...

Property Value Inheritance

Hello, After much searching on MSDN and other sources I have basically found that "some" Dependancy Properties do indeed support property value inheritance similar to WPF. However, as far as I can tell, there is no definitive list of which properties do, and which do not. I know Font properties, for example, do; yet HorizontalContentAli...

DependancyProperty attach to a property of a property

I have a workflow with a property in it, declared like this: public Person userAccount {get;set;} Person is a class with it's own properties (like Person.Name) and with WF I can bind to the userAccount property fine yet I can't seem to bind to the userAccount.Name. Is it possible to do this? If so what do I need to change? ...

How do I make Binding respect DependencyProperty value coercion?

I have a control with a DependencyProperty with a CoerceValueCallback. This property is bound to a property on a model object. When setting the control property to a value that causes coercion the Binding pushes the uncoerced value to the model object. The property value on the control is coerced correctly. How do I get the Binding to ...

DependencyProperty Strangeness

I've put together a WPF application using ObservableCollection and Dependency Properties which is cool because I just have to add an item to the Observable Collection and it shows up automatically, e.g. I display the objects in the collection as boxes on the screen in a wrappanel, each box showing its "Title". So then I wanted to have e...

WPF Dependency Property question ... need advice on what to do in this particular scenario:

I am attempting to create a sukodu (like crossword) player in WPF, and I realize that I have a whole bunch of controls that will need to know the sudoku grid to function. Because of this, I think the Sudoku Grid object would be a good candidate to create a dependency property. I am about to start the work, but I have some lingering ques...