dependency-properties

WPF - What to do when a Dependency Property is another Control in the XAML

I'm hoping this will be my last question today. I'm in a hurry and google is not helping much (that or I'm searching the wrong places). I created some custom properties and behaviors so my RadioButtons can alter my labels Content and the mask of my TextBoxes. I could pass a String as a property, but how do I pass another control as a p...

Can not change own property in style

I'm creating dependency property in my custom controll class DataPoint: public abstract class DataPoint : Control { public Color BaseColor { get { return (Color)GetValue(BaseColorProperty); } set { SetValue(BaseColorProperty, value); } } public static readonly DependencyProperty B...

Unable to create a Collection Type Dependency Property

I'm trying to create a custom list which features a List of objects. Though when this is set both in the Xaml and the code behind I get a "Incorrect markup error". Below is how I'm settings up the PropertyKey and Property. private static readonly DependencyPropertyKey ItemSourcePropertyKey = DependencyProperty.RegisterReadOnly( ...

Keeping track of dependency property value changes at global level

Hi, 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 implemented, so if user makes any change in canvas we ask him to save the document bef...

Making control with attached property in code behind (WPF).

I have UserControl1 and I want to create it's instance and set attached property for it in the code behind of the other UserControl2. The other words, I have in the UserControl2: <UserControl2> <Canvas> </Canvas> </UserControl2> And I want to do: <UserControl2> <Canvas> <UserControl1 Canvas.Left="100" ... /> </Canvas> </...

Multiple user controls share collection dependency property

Hi, I have implemented my own usercontrol based on listboxes. It has a dependency property with type of a collection. It works fine when I have only one instance of the usercontrol in a window, but if I have multiple instances I get problem that they share the collection dependency property. Below is a sample illustrating this. My user ...

XAML StoryBoard StackPanel

Hi, I am trying to add a storyBoard to my stack panel and bind the trigger to a code behind property, but the stackpanel is not responding to the property changes. here is the code: <Window x:Class="DirectAccess.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microso...

XamlWriter loses binding - ok! but how to keep the value? (ItemsControl)

hi, i know the standard XamlWriter does not persist bindings. but what really stinks is that the current value the binding holds does not get serialized too. my current - really stupid - workaround is to create a DependencyProperty fooProperty and the property foo. and also a property foo2. the Change-eventhandler of foo then writes it...

Func property on user control

I have a user control which I would like to add a dependency property of type Func so I can assign it a method handler in XAML. However, this will cause an XAMLParseException: 'Func`2' type does not have a public TypeConverter class. What am I doing wrong? Do I need to implement a TypeConverter for Func or is there a better way? The Fun...

Silverlight DependencyProperty.SetCurrentValue Equivalent

I'm looking for a SL4 equivalent to .NET 4's SetCurrentValue API, which would appear to be exactly what I need for my scenario. In short, I'm writing an attached behavior that updates the value of a given property at appropriate times. However, I don't want it to overwrite any bindings that are set on that dependency property. I merely ...

AttachedProperty not propagating to children?

Trying to create my own custom AttachedProperty for a WPF DependencyObject failed to actually do what I wanted it to do, and I am a bit worried that I (again) did not understand a WPF concept fully. I made a very simple test class to show where my problem lies. From the MSDN Documentation, I copied public class TestBox : TextBox { ...

DataBinding in an ItemsControl to a custom UserControl property

I am having major problem in Data Binding. I have a stackpanel with an ItemControl in my MainPage.xml: <StackPanel> <ItemsControl x:Name="TopicList"> <ItemsControl.ItemTemplate> <DataTemplate> <local:TopicListItem Tit...

Why doesn't this Silverlight 4 DependencyObject's DependencyProperty getting data bound?

I have no idea why data binding is not happening for certain objects in my Silverlight 4 application. Here's approximately what my XAML looks like: <sdk:DataGrid> <u:Command.ShortcutKeys> <u:ShortcutKeyCollection> <u:ShortcutKey Key="Delete" Command="{Binding Path=MyViewModelProperty}"/> </u:ShortcutKeyCollection> </u...

WPF DataBinding: Bind to a property that references two other properties

Basically, how do I bind (one-way) to a textbox named txtFullName. Initially, any text in the text box gets cleared/blanked out since ToString returns "". But, when I make changes to FirstName or LastName it does not update the binding against FullName. Any way to do this? Also, is there any way to bind to a method (not just a field)? T...

WPF: How to make a base class' dependency property read-only_

I have a class public class NavigableViewport3D : Viewport3D. The class should hide the the Viewport3D.Camera property, so that it becomes read-only. Here's what I have so far: public class NavigableViewport3D : Viewport3D { protected static readonly DependencyPropertyKey CameraPropertyKey = DependencyProperty.RegisterReadOnly( ...

Wpf UserControl and MVVM

I am thinking about writing a WPF User Control for my application. I am using MVVM in my application. User control's may require Dependency Properties that can be set my Parent View. when using MVVM, the idea is that the Parent View will eventually create a binding between the UserControls DP with Parent View's VM) Dependency Properti...

Change TextDecoration programmatically

Hi, I want to underline a text element programmatically in C# (I'm using WPF). I have a DependencyProperty: public TextDecorationCollection TextDecoration { get { return (TextDecorationCollection)GetValue(TextDecorationProperty); } set { SetValue(TextDecorationProperty, value); } } public stat...

WPF Triggers and DependencyProperties or How to get Validation.HasError for many fields.

This problem has several ways of being solved and that explains the complex title. I have a object that can be changed in a form in my WPF app. I wan't the save button to be Unenabled when there are validation errors in the form. I'm using IDataErrorInfo to notify to UI when there are errors and then I wan't a trigger on DataTemplate t...

Custom Workflow Activity - Update UI when property changes

Hello all and thanks for reading. I am rather new to WF programming, so I apologize ahead of time if my question doesn't make sense. I am attempting to code a custom workflow activity for use in SharePoint designer. So far I have gotten the designer to succesfully display my custom action, along with the dependency properties I have re...

How to bind a WPF control value to a method?

Imagine I have a TextBox that it's Text should be equal to the number of running processes in the machine. How to make it to update without using timers? Is there a way using Dependency Property or Bindings? ...