3

Controls like the TextBox use TwoWay Binding by default

<TextBox Text="{Binding Text1}" />

However with Custom User Controls, I will need something like

<local:UserControl1 Text="{Binding Text1, Mode=TwoWay}" />

Is there a way I can set bindings on a property to use TwoWay Bindings by default?

Athari
  • 33,702
  • 16
  • 105
  • 146
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805

1 Answers1

5

When you declare property, use FrameworkPropertyMetadataOptions.BindsTwoWayByDefault.

public DependencyProperty SomeProperty =
    DependencyProperty.Register("Some", typeof(bool), typeof(Window1),
        new FrameworkPropertyMetadata(default(bool),
            FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
Athari
  • 33,702
  • 16
  • 105
  • 146