Is there a way to specify a custom dependency property's default binding mode and update trigger?

C#Data BindingDependency Properties

C# Problem Overview

I would like to make it so that, as default, when I bind to one of my dependency properties the binding mode is two-way and update-trigger is property changed. Is there a way to do this?

Here is an example of one of my dependency properties:

public static readonly DependencyProperty BindableSelectionLengthProperty =
        new PropertyMetadata(OnBindableSelectionLengthChanged));

C# Solutions

Solution 1 - C#

When registering the property, initialize your metadata with:

new FrameworkPropertyMetadata
    BindsTwoWayByDefault = true,
    DefaultUpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged

Solution 2 - C#

In the Dependency Property declaration it would look like this:

public static readonly DependencyProperty IsExpandedProperty = 
        DependencyProperty.Register("IsExpanded", typeof(bool), typeof(Dock), 
        new FrameworkPropertyMetadata(true,

public bool IsExpanded
    get { return (bool)GetValue(IsExpandedProperty); }
    set { SetValue(IsExpandedProperty, value); }


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJustinView Question on Stackoverflow
Solution 1 - C#Diego MijelshonView Answer on Stackoverflow
Solution 2 - C#Paul MatovichView Answer on Stackoverflow