dependency-properties

Same Dependancy property (DP), Multiple classes

Hi, VS has thrown a useless exception which I think is caused by the fact I have multiple DP's in two similar classes with the same name. the classes are add/edit contact so they share a number of properties, my problem is this. I can register a property as: DependancyProperty.Register( /*...*/ ); or: MyDP.AddOwner( /*...*/ ) pr...

how to debug dependencyproperty.unsetvalue errors when innerexception is null

I have a custom login usercontrol that has a normal textbox and a passwordbox. Blend refuses to cooperate with the passwordbox saying that "DP.UnsetValue" is not valid for PasswordChar property. However the project compiles and runs fine in blend or in VS2010. The cider designer in vs2010 doesn't seem to mind the error because it actua...

Setting XAML attributes gets overwritten at runtime?

When I use the following line, implementing a templated control from a Silverlight class library; <labelSliderControl:SliderControl x:Name="sldX" Label="X" Value="4" /> I see in the VS Disign view the Slider getting the value of 4. But when I run the app the Slider starts at 0. So when I change the attribute in XAML I can see the c...

WPF: arranging collection items in a grid

Hi, I would like to arrange items of a collection in a grid with a specific number of columns and rows (say 4x6). Each item exposes the dependency properties (integer) X and Y and should be placed in the relevant cell of the grid. Note that the collection can change during runtime which should update the grid items. I couldn't find any ...

WPF: XAML property declarations not being set via Setters?

I have a WPF application where I'm using dependency properties in codebehind which I want to set via XAML declarations. e.g. <l:SelectControl StateType="A" Text="Hello"/> So in this example I have a UserControl called SelectControl, which has a property called StateType which manipulate some other properties in it's setter. To help...

Calculated Dependency Properties without callback?

In a poco view model I might have a calculated property that pulls data from several different properties inside its get. When these properties values change I need to remember to call OnNotifyPropertyChanged for the calculated property. I was thinking that any line of code where I say NotifyPropertyChanged is not testable code, so I a...

Very basic DependencyProperty problem in WPF - tyring to bind to a complex object

I'm just getting started with WPF. I have TextBox declared in xmal like so: <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=TestComplex.Something, Mode=TwoWay}"/> In my code behind I have registered the property that I am trying to bind to like so: public TestComplexObject TestComplex { get { return (TestComplex...

Spring bean fields injection

Using Spring IoC allows to set bean properties exposed via setters: public class Bean { private String value; public void setValue(String value) { this.value = value; } } And the bean definition is: <bean class="Bean"> <property name="value" value="Hello!"> </bean> Is there any existing plugins/classes for S...

What is the proper way to create a dependency property bindable to an observable collection?

Hi, I need to create a dependency property on a custom control. The problem is that the propertyChangedCallback does not get called when the collection changes. How should I properly handle this scenario? I am afraid of memory leaks caused by simply event hooking to the CollectionChanged event during the initial property change (when t...

WPF ValidationRule with dependency property

Suppose you have a class inheriting from ValidationRule: public class MyValidationRule : ValidationRule { public string ValidationType { get; set; } public override ValidationResult Validate(object value, CultureInfo cultureInfo) {} } in XAML you are validating like this: <ComboBox.SelectedItem> <Binding Path="MyPath...

Two way binding between textbox from parent silverlight's page to another local silverlight user control's textbox.

I have used DependencyProperty to pass value from textbox at silverlight page to external silverlight user control located in same page and that works fine. But the problem is I could not bind the Textbox in page in reverse way. i.e. when i need to have changes in parent page when its usercontrol's textbox text is changed. The XAML: ...

Storyboard changing property but not reflected in UI

I have this method fired on a button click. MyObj is an extended Control type with two properties CenterX and CenterY with backing dp CenterXProperty and CenterYProperty. With the animation playing the CenterX and CenterY properties of MyObj are changing, but I can't see any movement of the object. private void MoveMyObjectsWithAnimat...

Silverlight Control property as a data binding Source and View-Model property as target

I have a property on a Silverlight control that a ViewModel wants to bind to. The ViewModel need to told of changes to the property NOT the other way around Syntax like <MyControl ViewPort="{Binding VMProperty}"/> Declares ViewPort as the Target, in this instance ViewPort is the source of the data. I know I could make it TwoWay bind...

How do you expose a dependency property of a private, internal object via the interface of the object that contains it?

We have a custom panel class that animates its children via an internal DoubleAnimation object. However, we want to expose the animation's Duration dependency property as a public property of our panel so the user can change it in their XAML when using our panel. But we don't want to expose any other part of the animation object, just ...

How to set generic dependency properties of validation rules in WPF?

The background Maybe it is not necessary, but I am afraid that single line question would be too complex. So... I had min-max generic range validator (RangeValidator), because XAML does not work with generic classes I created simple derivative IntRangeValidator which would set int as generic type, because in current case I need validat...

How Dependency Property works?

I have next dependency property: public static DependencyProperty RequestObjectProperty = DependencyProperty.Register("RequestObject", typeof(RegistrationCardSearch), typeof(RegCardSearchForm),new UIPropertyMetadata(Changed)); private static void Changed(DependencyObject d, DependencyPropertyChangedEventArgs e) { Me...

Problem sending UIElements via DependencyProperty in wpf

I have a usercontrol with a dependencyproperty that takes oen UIElement. So fare so good, the problem is I can not find the element's children. I think the problem is my lack of knowledge, could anyone tell me what the problem is and a possible solution? I have made a small test-program like this Usercontrol codebehinde: public UIEle...

How to create a Dependency property on an existing control?

I have been reading on Dependency properties for a few days and understand how they retrieve the value rather than to set/get them as in CLR properties. Feel free to correct me if I am wrong. From my understanding all WPF controls like a TextBlock, Button etc that derive from DependencyObject would also contain dependency properties to ...

Setting SizeToContent fom Child UserControl causes FatalExecutionEngineError

I've added a dependency property to my view base class, that is supposed to allow the child UserControls to set some properties on the parent window, one being SizeToContent. When my OnSizeToContent method runs, when it tries to change the main windows's SizeToContent from WidthAndHeight to Manual, I get this odd error: FatalExecutionEn...

How do you call identically named properties on different types which don't share an interface?

I have a DataTemplate that needs to set the IsSelected property on an ItemsControl's container (such as TreeViewItem, ListViewItem or ComboBoxItem). However, it doesn't know the type of the container until it's passed in to it. Since IsSelected isn't part of a common base class or interface, nor is it a common dependency property regis...