简体   繁体   中英

How can I mark a `DependencyProperty` as `BindsTwoWayByDefault` in UWP?

In WPF you could mark a DependencyProperty on a custom control as binding Mode=TwoWay by default using FrameworkPropertyMetadataOptions.BindsTwoWayByDefault , but FrameworkPropertyMetadata seems to be missing in UWP. The UWP documentation on the {Binding} markup extension says that the default mode may change, but gives no indication on how to affect it.

Mode

Specifies the binding mode, as one of these values: "OneTime", "OneWay", or "TwoWay". These correspond to the constant names of the BindingMode enumeration. The default depends on the binding target but in most cases it is "OneWay". Note that this differs from the default for {x:Bind}, which is "OneTime".

How can you change the default binding mode for a UWP XAML Dependency Property on a custom control?

The current UWP SDK doesn't have any support for affecting the default BindingMode for a DependencyProperty ; that is only possible within WPF.

On UWP all {Binding} have BindingMode.OneWay as default, while {x:Bind} has BindingMode.OneTime

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM