一个项目中使用的MVVMCross默认绑定方式
MVVMCross default binding mode used in a project
我从另一个开发人员那里继承了一个 Xamarin MVVMCross 项目。我想知道如何获得使用的默认绑定模式以及如何更改它。
在 MvvmCross 中,当使用 MvvmCross 定义的绑定(虚拟 属性 bindings/Custom 绑定)时,默认值 binding mode 通常是 Two-Way
。本机属性通常是 One-Way
,因为默认情况下没有 return 机制(View to ViewModel)。
来自 MvvmCross Custom binding 的注释:
Where MvvmCross had created new bindings, then this [Two-Way binding] is very often the
default binding mode MvvmCross tries to use.
Windows 和 Xaml 除外:
In Windows/Xaml, this [One-Way binding] is very often the default binding mode - so it
is the mode used when no other is selected.
, Mode=$WhichMode$
其中 $WhichMode$
是以下之一:
- 单向
- 单向
- 来源
- 双向
- 一次性
- 默认
示例使用 Android AXML
local:MvxBind="Text UserName, Mode=OneWay"
使用代码库绑定你可以使用:
OneWay()
TwoWay()
OneWayToSource()
OneTime()
示例:
var set = this.CreateBindingSet<MyView, MyViewModel>();
set.Bind(cardLabel)
.For(v => v.Text)
.To(vm => vm.UserName)
.OneWay();
set.Apply();
我从另一个开发人员那里继承了一个 Xamarin MVVMCross 项目。我想知道如何获得使用的默认绑定模式以及如何更改它。
在 MvvmCross 中,当使用 MvvmCross 定义的绑定(虚拟 属性 bindings/Custom 绑定)时,默认值 binding mode 通常是 Two-Way
。本机属性通常是 One-Way
,因为默认情况下没有 return 机制(View to ViewModel)。
来自 MvvmCross Custom binding 的注释:
Where MvvmCross had created new bindings, then this [Two-Way binding] is very often the default binding mode MvvmCross tries to use.
Windows 和 Xaml 除外:
In Windows/Xaml, this [One-Way binding] is very often the default binding mode - so it is the mode used when no other is selected.
, Mode=$WhichMode$
其中 $WhichMode$
是以下之一:
- 单向
- 单向
- 来源
- 双向
- 一次性
- 默认
示例使用 Android AXML
local:MvxBind="Text UserName, Mode=OneWay"
使用代码库绑定你可以使用:
OneWay()
TwoWay()
OneWayToSource()
OneTime()
示例:
var set = this.CreateBindingSet<MyView, MyViewModel>();
set.Bind(cardLabel)
.For(v => v.Text)
.To(vm => vm.UserName)
.OneWay();
set.Apply();