dependency-properties

Displaying FontFamily in Combobox

Hi. My goal is to manipulate the text-styles of my application via DependencyProperties. I got a diagram in which the texts are to be manipulated in size, fontfamily, color, etc. So I'd like to use an interface similar to a rich text editor like Word. I'm using this code in my TextStyleVM http://shevaspace.blogspot.com/2006/12/i-have-s...

Custom Fill Property on PathGeometry in Silverlight

I've been looking at (and getting confused by) Dependency Properties - I'm not sure if this is what I need or if there is something else. I'm looking to something very specific with <Path.Data/> children in Silverlight, in particular <PathGeometry/>, <EllipseGeometry/>, etc. While the <Path/> element has a .Fill property, I'd like to a...

WPF Exposing a calculated property for binding (as DependencyProperty)

Hello, I have a complex WPF control that for some reasons (ie. performance) is not using dependency properties but simple C# properties (at least at the top level these are exposed as properties). The goal is to make it possible to bind to some of those top level properties -> I guess I should declare them as DPs.(right? or is there so...

Adding Enumeration Value to Silverlight Attribute/Property

In the <ImageBrush/> element, there are AlignmentX and AlignmentY attributes with values Left/Center/Right and Top/Center/Bottom, respectively. What I'm wanting to do is set my own value in, for example, AlignmentX either as a value or as another enumeration like AlignmentX="HalfCenter" where HalfLeft equals my own value (halfway betwee...

Binding doesn't work in ListView

Hello. I have a wpf control named DataPicker which has a dependency property named SelectedDate. In simple cases it works well but there is one case where binding fails and I can't understand why: when i try to bind it inside a ListView. For example, I have class (INotifyPropertyChanged is implemented) public class TestClass : IN...

Synchronize Bindings of multiple Properties in a UserControl

I have an ugly race condition with a WPF usercontrol, which is some kind of extended ComboBox: The UserControl mainly defines two bindable DependencyProperties, one is the selected item, another one is a list, from which the selected item can be chosen. Both are bindable, so the control may be initialized with or without a selected item ...

Dependency Properties, change notification and setting values in the constructor

Hello, I have a class with 3 dependency properties A,B,C. The values of these properties are set by the constructor and every time one of the properties A, B or C changes, the method recalculate() is called. Now during execution of the constructor these method is called 3 times, because the 3 properties A, B, C are changed. Hoewever thi...

DependencyProperty ValidateValueCallback question

Hello, I added a ValidateValueCallback to a DependencyProperty called A. Now in the validate callback, A shall be compared to the value of a DependencyProperty called B. But how to access the value of B in the static ValidateValueCallback method validateValue(object value)? Thanks for any hint! Sample code: class ValidateTest : Depend...

Dependency Property Binding Not Updating Target

I have a custom dependency property: public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register("HeaderProperty", typeof(string), typeof(RadAdjustableSlider)); public string Header { get { return (string)GetValue(HeaderProperty); } set { ...

IEnumerable DependencyProperty throws errors when set in XAML

I have a custom control Workspace that inherits from Control and within it is a DependencyProperty that I need to contain a user-specified IEnumerable<IFoo> (I have also tried making it an non-generic IEnumerable). Public Shared ReadOnly FoosProperty As DependencyProperty = DependencyProperty.Register("Foos", GetType(IEnumerable(Of IFo...

Setting a property on the ViewModel from the View in WPF

I have a dependency property on my ViewModel which is the DataContext for my View. The ViewModel has no reference to the View. The property on the ViewModel is going to reference a control on the view, but I need to be able to set this property in XAML. How is this possible? One thought I had was to develop a custom control which ha...

ImageSource dependency property on a user control - XAML value set throws

I've created a small user control consisting of a button whose content is an Image. I created an "ImageSource" dependency property on the user control in order to bind to it from the Image inside the button. However in the XAML where I placed an instance of my user control setting the property throws an error at runtime : <ctrl:ImageBu...

Binding to UserControl property inside tooltip not working

Hello, I am trying to do some simple binding to a property inside my usercontrol. Does anyone know why this doesn't work? It works when the TextBlock is outside the Tooltip. Thanks! MasterPage.cs: MyUserControlInstance.DisplayName = "Test"; MyUserControl.xaml <ToolTipService.ToolTip> <ToolTip Template="{StaticResource ToolTipT...

Dependency Property WPF

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 not tell the exact way they work from inside. I mean they are implemented as static but still applies to all objects. Second point of con...

Simpler Dependency Properties?

Hello. I'm being used to create Dependency Properties for my custom controls. But i'm really tired of defining static fields, populating them in the constructors, coding the standard properties and later the events, plus casting and validating objects, all despite the help of copy & paste and code snippets. So, the question is... is the...

DrawingVisual DependencyProperty not Inheriting from Parent

I have a class that inherits from DrawingVisual. It declares a DependencyProperty which, when registered, should inherit its value from a parent. I then create a parent-child relationship between two instances of this class. I set the parent DependencyProperty but the child's DependencyProperty does not return the parent's value. Can...

why doesn't a polyline redraw when I change its Points collection to reference a different collection?

Hi, I'm still fairly new to silverlight, so hopefully this is an elementary question: I have a polyline whose 'Points' (type: PointsCollection) property is bound to a PointsCollection public member, Pts, in my view model class. When I add/remove points from ViewModel.Pts, the polyline redraws correctly without any problem. However, if...

Designing a WPF user control with DependencyProperties and a backing object

I have an object in my business layer (let's call it Car for example's sake), and I have created a UserControl (CarIcon). The user control has a property that is a Car object and when the Car object is set it calls a method that configures the various properties of the user control. Now I am rewriting it to use dependency properties so...

How does EntityState, HasChanges, HasPropertyChanges work on Partial Classes ?

Hi, I have a class coming from EntityFramework which I have extended with a few properties in a partial class. I expose and edit the values of these properties in my interface and everything works fine. But, I want to detect the change of value in the properties in my ViewModel, and while investigating the EntityState, HasChanges, HasPr...

WPF - Dependency Properties Error

Hello again. I'm working on a WPF project, and my intention is to make two specific RadioButtons alter properties of another specified Component. But for now, i'm just trying to store a String inside the RadioButton. For that, I've created a behavior class: public class AdjustBehavior : Behavior<RadioButton> { With this property...