在 WPF 中,您可以使用 FrameworkPropertyMetadataOptions.BindsTwoWayByDefault
将自定义控件上的 DependencyProperty
标记为绑定(bind) Mode=TwoWay
,但是 UWP 中似乎缺少 FrameworkPropertyMetadata
。 UWP documentation on the {Binding}
markup extension说默认模式可能会改变,但没有说明如何影响它。
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".
如何更改自定义控件上 UWP XAML 依赖属性的默认绑定(bind)模式?
最佳答案
当前的 UWP SDK 不支持影响 DependencyProperty
的默认 BindingMode
;这只有在 WPF 中才有可能。
在 UWP 上,所有 {Binding}
默认都有 BindingMode.OneWay
,而 {x:Bind}
默认有 BindingMode.OneTime
关于c# - 如何在 UWP 中将 `DependencyProperty` 标记为 `BindsTwoWayByDefault`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48198983/