dependency-properties

DependencyProperty Callback-Method not called

Hi, I create a UserControl (TableWithFilter.xaml) with a dependency property (source). The UserControl is a Table with a source property for the different items. I created the XAML and set the source property via the XAML Binding. So far so good. But if the value of the dependency property is changed, the defined callback method is not...

WPF Dependency Property for Custom Control

I'm a bit in a mess with how to set a Dependency Property for Custom Control. I created Custom Control, so it derives from Control class. public class CustControl : Control { static CustControl() { DefaultStyleKeyProperty.OverrideMetadata(typeof(CustControl), new FrameworkPropertyMetadata(typeof(CustControl...

Using enum as a dependency property in WPF

I try to use enum type as a dependency property in my custom control, but always get an error: public enum PriceCategories { First = 1, Second = 2, Third = 3, Fourth = 4, Fifth = 5, Sixth = 6 } public static readonly DependencyProperty PriceCatProperty = DependencyProperty.Regi...

How to unanimate WPF DependencyProperty?

After running WPF animations on dependency properties in code behind, the dependency properties can no longer be set using SetValue. They can only be changed through animations. I want to change a dependency property, some times through short animations, sometimes immediately in code. So how can I remove the animation from a dependency...

Nested controls with the same property: Attached property vs. data binding?

This is what I want: I have a custom Panel which arranges a certain type of item. My Panel also has a few dependency properties (ArrangeMode, MinDate, ...), which influence the rendering. Example: <TimeLinePanel ArrangeMode="Compact" MinDate="..."> <TimeLineItem ... /> <TimeLineItem ... /> </TimeLinePanel> To be able to data-b...

C#/WPF: Dependency Property is not updating the bound Property?

Hello, I'm trying to bind a Dependency Property from my UserControl to my MainViewModel. This is how the DependencyProperty looks like: public static DependencyProperty ItemHasChangesProperty = DependencyProperty.Register("ItemHasChanges", typeof(boo...

Basic WPF databinding question

I have another WPF databinding question... one that I haven't found an answer to anywhere, and this surprises me since it seems like it is very basic. Essentially, I have a string in code behind that I would like to establish a two-way binding with with a textbox in my GUI. I thought it was a simple matter of creating a DependencyPrope...

wpf how to tell when databinding has finished?

Hi, I've got a custom control which has a DependencyProperty MyAnimal - I'm binding an Animal Property on my ViewModel to the MyAnimal DependencyProperty. I've stuck a TextBox on the Control so I can trigger an Event - whenever I trigger the event the MyAnimal property has been set - however if I put a break point on the Setter of the ...

DependencyProperty problem with Double and Single

Silverligh 4, VS 2010. Making a Custom Control. (Non just UserControl, but public class HandPart : Control, and a template in \themes) Then I creating a new DependencyProperty with a helper snippet: #region SomeDouble (DependencyProperty) /// <summary> /// A description of the property. /// </summary> public Double SomeDouble { ...

WPF Custom Control "OnSourceTypeChanged" method is not invoked

Hey pals, let's put it short: I'm trying to create a WPF custom control that inherits from WPF Image. I have added a dependency property called "Source Type" to my control so that when databound it sets the "Source" property of the image to what I want. But the problem is that my method to perform the source changing task (i.e "OnSourc...

Silverlight DependencyProperty problems

Here's the situation: I have a custom TextBox control that contains multiple other TextBox controls. I need to turn IsTabStop off in the parent control, but I still want to expose a new IsTabStop property, which the sub-textboxes are template-bound to. I wrote the following code: using System.Windows.Controls; public class CustomTextBo...

Databinding with INotifyPropertyChanged instead of DependencyProperties

I have been wrestling with getting databinding to work in WPF for a little over a week. I did get valuable help here regarding the DataContext, and I did get databinding to work via DependencyProperties. While I was learning about databinding, I came across numerous discussions about INotifyPropertyChanged and how it is better than DPs...

WPF: dependency property with type of Template - where to get default template (to set as default value)?

Hi, I am subclassing an ItemsControl (let's call it EnhancedItemsControl), and I would like to expose ScrollViewerTemplate dependency property, which would allow the user to optionally specify his own template for used ScrollViewer. I am doing it like this: public ControlTemplate ScrollViewerTemplate { get { return (ControlTemplate)G...

How does inheritance of FontSize in silverlight tree work?

If I have a ChildWindow in Silverlight I can apply the FontSizeProperty and it is inherited by child items. <controls:ChildWindow FontSize="14"> <StackPanel> <TextBlock Content="Hello"> <TextBlock Content="World"> </StackPanel> </controls:ChildWindow> Now that's fine if you want the whole page to have t...

How to set DataContext without clearing dependency properties?

I'm using a viewmodel pattern, so my DataContext for my custom user control is actually a viewmodel wrapper for the real data. My custom control can contain hierarchal instances of the custom control. I set up a DependencyProperty in the custom control for the real piece of data, with the hopes of creating a new viewmodel for that data...

WPF: Binding ContextMenu to visual parent

I know ContextMenus aren't part of the visual tree, but I've been trying to bind the Visibility property of a contextmenu to a property on it's parent UserControl. So far I've tried ancestor binding and experimented with a converted, but the only way that seems remotely feasible at the minute is to use a MultiValueConverter and reflectio...

Problem with Binding Dependency Property on a UserControl

I have a two userControls (IconUserControl & DisplayUserControl), I'm having a problem with binding dependency properties, here's some detail: IconUserControl has a bool DP of IsDisplayShown DisplayUserControl has a bool DP of IsDisplayShown In the XAML I have: <local:DisplayUserControl x:Name="DisplayUserControl...

DependencyProperty value not getting set through data binding

I have a class which has a DependencyProperty member: public class SomeClass : FrameworkElement { public static readonly DependencyProperty SomeValueProperty = DependencyProperty.Register( "SomeValue", typeof(int), typeof(SomeClass)); new PropertyMetadata( new P...

WPF seemingly super-simple dependency property

I'm puzzled. I'm trying to create a user control called TranslationView. It consists pretty much entirely of a single ListView. I don't think that's important now however, because I cannot even compile my code-behind. This is the code-behind for the user control: namespace Subster { /// <summary> /// Interaction logic for Tr...

checkbox not setting dependency property

I have this DP: public bool ShowEntireHierarchyEx { get { return (bool)GetValue(ShowEntireHierarchyExProperty); } set { SetValue(ShowEntireHierarchyExProperty, value); } } public static readonly DependencyProperty ShowEntireHierarchyExProperty = DependencyProperty.Register("ShowEntireHierarchyEx"...