Is there a way to declare the / DependencyProperty property to use the TwoWay default binding if its binding?

Controls such as TextBox use TwoWay Default Binding

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

However, using custom controls, I need something like

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

Is there a way to set property bindings to use TwoWay default bindings?

+3
source share
1 answer

When you declare a property, use FrameworkPropertyMetadataOptions.BindsTwoWayByDefault .

 public DependencyProperty SomeProperty = DependencyProperty.Register("Some", typeof(bool), typeof(Window1), new FrameworkPropertyMetadata(default(bool), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); 
+5
source

Source: https://habr.com/ru/post/913711/


All Articles