dependency-properties

How can I extend this dependency property example to recreate a DockPanel.Dock="Top"-like dependency property?

I'm trying to get a better understanding of what dependency properties and what they are not. I've built the example below which enables a combobox's choices to change based on how the user moves a slider. In creating this I learned that dependency properties actually have nothing to do with INotifyPropertyChanged as is used in ViewMode...

I've created an Attached Property, now how do I use it?

I'm trying to determine if Attached Behaviors are something we need in building controls for the forms in our application. Hence, I not only want to know how to create Attached Behaviors but want to see real instances in which they are used to solve problems. I used this MSDN article to create a UserControl with an attached property in ...

Silverlight: Label does not evaluate Binding of custom DependencyProperty

Hi everyone! I have a Silverlight 3 Label which I connect to a ComboBox using the Target Property of the Label. According to MSDN the Label class iterates through the targets bindings and searches the sources for meta data to determine the content of the Label. This actually works as long as the target is a standard control. But if I u...

Cannot databind DependencyProperty

Hi all I have a UserControl with a DependencyProperty. I set it's value in the host window using a data binding expression. However, it doesn't work as expected. Snippet from the user control's codebehind: public class ViewBase : UserControl { public static readonly DependencyProperty ViewModelProperty = DependencyProperty...

Dependency property not working, trying to set through style setter.

I am trying to set up a custom style for my newly made usercontrol, however i am getting the error : "Cannot convert the value in attribute 'Property' to object of type 'System.Windows.DependencyProperty'." I thought i had set up Dependency properties but it seemed this was not the case, so i did some research and added: public stat...

Binding to a UserControl's DependencyProperty

I'm trying to adapt a soltuion for the WPF toolkit's calendar from http://msdn.microsoft.com/en-us/magazine/dd882520.aspx but I'm having problems getting a binding on the usercontrol to work. I've tried using FindAncestor and ElementName, but I just get a binding error. I think it might have something to do with the tooltip and it's Dat...

InvalidOperationException on object from a thread that's done

In a WPF application I had a BackgroundWorker thread creating an object. Let's call the object foo. Background worker code: SomeClass foo = new SomeClass(); // Do some operation on foo // Set some dependency property on the main class to foo this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate { SetV...

Defining TextEdit DependencyProperty

Hello, I try to define TextEdit DependencyProperty, because I want to get a TextEdit "Text" value, which was inputed by user. Then I want to use this value in another static class, which forms an SQL query depending on that entered "Text". My Dependency Property: public class FrameworkElement : UIElement { public static read...

How to design a wpf dependeny Property to support the path to image ?

To describe my problem i have created a small application. At first the Usercontrol: <UserControl x:Class="WpfApplication10.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="This" DataContext="{Binding ElementName=This}" > ...

Why dependency properties?

Why did Microsoft go the route of making dependency properties and dependency objects instead of using reflection and maybe attributes? ...

Issue binding Silverlight Custom Control dependency property to Model property

Hi, I have a data navigation user control in Silverlight which opens a child window where the user can enter search criteria and when they press 'Apply' it's suppose to update the bound property in the ViewModel (MVVM pattern.) The links are: SearchDialog <--> DataNavigator <--> MyView <--> MyViewModel The dependency property in Search...

Add multiple Property Metadata to a Dependency Property in a Workflow Activity

Hi, I am building a number of Custom Activities in Windows Workflow and I need to add a DependencyProperty which can list a number of values for that property which the user can then select when using the activity. e.g. True or False. I know how to simply pass a default using the PropertyMetadata, and presume that I will have to pass ...

WPF ReadOnly Dependency Properties using MVVM

Hi, I've recently overridden the DevXpress WPF grid to give myself a SelectedObject property that I can access from my loosely bound ViewModel. I've made a SelectedObject dependency property and have it bound OneWayToSource in my XAML. Everthing works fine, but if I try to make it ReadOnly (for completeness) I get a compile error and ...

Can a WPF window inherit property values from its owner window?

I'd like the child windows in my application to inherit WPF dependency properties from their parent window. If I set TextOptions.TextRenderingMode="ClearType" on my main window (I'm using WPF 4), that value will apply to all child controls of the window. How can I make those values also apply to all child windows? (Window instances with...

WPF: How to accept both string and FrameworkElement in dependency property (like wpf Label does)?

Hi, I am creating a custom WPF control that should have several content slots. I'd like the user to be able to use either string, or a FrameworkElement as a value of property, for example: <!-- MyHeading is a string --> <MyControl MyHeading="Hello World" /> <MyControl> <!-- MyHeading is a FrameworkElement --> <MyControl.MyHeading> ...

Exposing DataGrid SelectedItem in parent UserControl in WPF

Hi there, I have a User Control with a Data Grid inside it which i re-use in a couple of different Pages and am using M-V-VM. How can I / is it possible to expose the Data Grid's SelectedItem dependancy property as a dependancy property on the User Control which contains it??? The goal being that in a Page using the control, i could ...

Add sub categories to a Dependency Property in a Workflow Activity

Hi all, I wish to create an workflow activity that has a dependancy property structure like this Setting Wait Period Days Hours Mins At the moment the code below will show Setting with the Wait Period as an Integer, but now need to expand it out to 3 sub child properties for Days, Hours and Mins. I understand i will have to cha...

workflow dependency property

I have a Person class with a name property. I have a custom activity that have this Person object as a dependency property. Now when I drop this custom activity into the workflow designer. I can see the Person in the property grid. From the designer I'd like to be able to specify the name of the person. Is this possible? Or the o...

Why does my Custom UserControl's dependency property not work with binding?

My Custom UserControl's dependency property will bind correctly if the value is statically defined in the XAML calling it, like this: ItemTypeIdCode="addresses" but not if the value is bound dynamically itself: ItemTypeIdCode="{Binding ItemTypeIdCode}" What do I have to do to my custom UserControl so that it's dependency property r...

How can make all my user control dependency values load before they control accesses their values?

When I call this custom control, I have to put the attribute values in the correct order since the third dependency property (ItemTypeIdCode) accesses the values of the first two (KeyField, ValueField) to look up data in the database, and if they come after the first attribute, then their values are empty. <controls:DropDown x:Name="The...