c# - 如何在 UWP 中将 `DependencyProperty` 标记为 `BindsTwoWayByDefault`?

标签 c# xaml uwp uwp-xaml

在 WPF 中,您可以使用 FrameworkPropertyMetadataOptions.BindsTwoWayByDefault 将自定义控件上的 DependencyProperty 标记为绑定(bind) Mode=TwoWay ,但是 UWP 中似乎缺少 FrameworkPropertyMetadataUWP 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/

相关文章:

wpf - 使用 WPF 和 MVVM 编辑 F# 记录

c# - UWP 应用程序和 .NET Core RC2 : cannot reference netstandard1. 4 个包

C# VS2017 IStringable 未引用异常使用 Windows.Data.Json

c# - 正确的 Resource.Load 路径是什么?

c# - 如何在 C# 中使用 "using"而不获取 "InvalidOperationException"?

c# - 单个或多个 MySqlDataReader

windows - 如何在 UWP 中捕获 PC 屏幕和录制音频?

c# - WCF 和身份验证

c# - 基于 WPF 中的 TextBox Focus 更改图像颜色?

c# - WPF中如何使用按钮导航到其他页面