dependency-properties

WPF: DataContext dependency property in non - GUI - classes?

Is it possible to have a dependency property "DataContext" in a class that is NOT derived from "FrameworkElement" (but it can be derived from "DependencyObject")? I already tried and created a class (which I added to Window.Resources), but the DataContext is always null. Any ideas? ...

WPF bind property to Dependency Property in child control

Ive created a custom UserControl that contains a single combobox. The currently selected value in the combobox is bound to the custom UserControls Dependency Property. XAML: <UserControl> <ComboBox ItemsSource="{Binding AllEntries}" SelectedItem="{Binding SelectedEntry}" /> </UserControl> Code behind: public part...

Visibility Binding using DependencyProperty

I've some simple code below that uses a ToggleButton.IsChecked property to set the Visibility of a TextBlock. It works fine. Since this doesn't quite fit in with my program's structure, I'm trying to bind the visibility of another TextBlock to a DependencyProperty of "this". It compiles fine, but it produces no effect. I'm doing some...

WPF, property in ValidationRule never set

I'm trying to bind a property in my DataContext to a property in a ValidationRule: public class ReleaseValidationRule : ValidationRule { // I want to bind a value from my DataContext to this property: public CheckboxViewModels ValidReleases { get; set; } ... } Based on this thread, I created the CheckboxViewModels class ju...

DependencyProperty keeps it's value after destruction

Scenario: A VB6 library calls a method in a .NET-Assembly through COM and with that opens a WPF-Dialog, which is contained in another .NET-Assembly that is early bound. This WPF-Dialog got a complex master/detail implementation over a DependencyProperty of type ObservableCollection on this dialog. The DependencyProperty looks something l...

WPF - property change notification from UserControl

I have two UserControls (uc1 and uc2) loading into a third UserControl (shell). Shell has two properties, uc1 and uc2, of type UserControl1 and UserControl2, and each have a DependencyProperty registered to their own classes called IsDirty: public static readonly DependencyProperty IsDirtyProperty = DependencyProperty.Register("IsDirty"...

Dependency property in User Control is null after assigning value

I have a user control, has a Frame as a dependency property public partial class NavigationBar : UserControl { public NavigationBar() { this.InitializeComponent(); } public Frame NavigationFrame { get { return (Frame)GetValue(NavigationFrameProperty); } set { SetValue(NavigationFrameProperty,...

WPF radio button binding - getting an error in this code here??

Trying to get radiobuttons binding working but getting a run time error with the code below. Want the radio buttons to act such that only one can be selected at a time, and that they bind correctly in a 2 way fashion. Error text is. "The invocation of the constructor on type 'testapp1.MainWindow' that matches the specified bin...

Why isn't my dependency property set when binding to it?

I have two collections displayed in my WPF application, and I'd like to have elements from one of them disabled in the other. Doing this I'm creating a custom control FilteringListBox that inherits ListBox, and I want to add some handling inside it to disable elements that are set in a collection set through a property on the FilteringLi...

DependencyProperty of Type Delegate

Hello, I have created an attached behavior that is used to execute a Delegate of type Func<bool> when the behavior is invoked. Below is the dependancy property definition. public static readonly DependencyProperty SendToDetailBehaviorProperty = DependencyProperty.RegisterAttached("SendToDetailBehavior", typeof(Func<bool>), typeof(ListD...

Pausing an animation rotation, setting the angle value, then resuming later?

I have a situation where I have a 3d Model that has a constant rotation animation. When a user touches the screen, I would like the rotation to stop, and the user's control to take over the animation of the rotation. I tried to do this by pausing the animation, setting the angle property of the rotation locally, then resuming the rotati...

Run Animation when Dependency Property Changes

I have created a UserControl with two dependency properties: Value and Color. The Color of the UserControl is dependent on the Value property. For example if Value=0 Color=Blue, Value=0.5 Color=Red and so on. This I have achieved using a custom converter that is bound to the Fill property, like so: <Ellipse Name="dotForeground" Stroke="...

Wpf styles and attached properties

Hi, I've been playing with behaviors and I came across a interesting issue. Here is my behavior: public class AddNewBehavior : BaseBehavior<RadGridView, AddNewBehavior> { public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.RegisterAttached("IsEnabled", typeof(bool), typeof(AddNewBehavior), new Framework...

Binding to property in nested objects in code behind.

The nested ViewModel is set to the MainWindow DataContext: var mainWindow = new MainWindow(); mainWindow.Show(); mainWindow.DataContext = new { MyProperty = new { MySubProperty = "Hello" } } It is easy to bind to MySubProperty in XAML: <Button Content="{Binding MyProperty.MySubProperty}"/> How can I do this bind...

Is it appropriate to thrown an exception from CoerceValueCallback

Is it appropriate to throw an exception from a CoerceValueCallback if a given value is invalid or should only ValidateValueCallback be used for DP-value-validation? ...

Update Dependency Property prior to program exit

I have created a dependency property of type Binary on a RichTextBox which allows me to bind to a FlowDocument which is in binary form (byte[]) within the ViewModel. This works well, the property converts to and back correctly. Whenever the RichTextBox looses focus then the value of the dependency property is updated with the new binary...

Binding a Value of a Custom Dependancy Property Silverlight

I have setted a property like this: public static readonly DependencyProperty ValorRegistadoProperty = DependencyProperty.RegisterAttached( "ValorRegistado", typeof(string), typeof(CampoInfo), new PropertyMetadata(new PropertyChangedCallback((d, e) => { System.Diagnostics.Debug.WriteLi...

WPF DataBinding: Grid ColumnDefinition Width to UserControl DependencyProperty

I'm not sure what I'm doing wrong, but I am attempting to align my user control with the ColumnWidth of my grid using DataBinding and DependencyProperties. I have a GridView on my Form Page which contains a two instances of a user control (Address). The address usercontrol contains a textlabel "header" so that I can name the user contro...

Silverlight Command Binding

I am looking at the following xaml: <Grid x:Name="LayoutRoot" Background="White"> <Button Content="Say Hello..." VerticalAlignment="Center" HorizontalAlignment="Center" my:ButtonService.Command="{Binding Path=SayHello}" my:ButtonService.CommandParameter="Bob"/> </Grid> I...

All WPF control properties are dependency properties. True or False?

While answering this question I noticed that I have never come across any property which is not a dependency property (WPF Controls, no 3rd party controls). Although, when I started with WPF I remember reading somewhere that "more then 90% of properties of WPF controls are dependency properties". Can anyone give examples/links of CLR pr...