控件可绑定属性的默认绑定模式在哪里找到?

huangapple go评论60阅读模式
英文:

Where to find the default binding mode of a control bindable property?

问题

无论何时处理BindableProperty,都有4种不同的绑定模式:

  1. TwoWay — 数据在源和目标之间双向流动
  2. OneWay — 数据从源到目标流动
  3. OneWayToSource — 数据从目标到源流动
  4. OneTime — 数据从源到目标流动,但仅在BindingContext更改时

根据文档所述:

> 大多数属性(如Rotation、Scale和Opacity)的默认绑定模式是OneWay。

然而,每当我阅读特定控件及其可绑定属性的文档时,我无法找到它们的默认绑定模式(例如Label TextProperty

问题是:我如何轻松获取控件可绑定属性的默认绑定模式?

英文:

Whenever dealing with a BindableProperty, there are 4 different binding modes:

  1. TwoWay — data goes both ways between source and target
  2. OneWay — data goes from source to target
  3. OneWayToSource — data goes from target to source
  4. OneTime — data goes from source to target, but only when the BindingContext changes

And as per the documentation says:

> The default binding mode for most properties such as Rotation, Scale, and Opacity is OneWay.

However, anytime I read the documentation of a specific control and its bindable properties, I'm not able to find about their default binding mode (e.g. Label TextProperty)

Question is: how do I easily get the default binding mode of a control bindable property ?

答案1

得分: 1

绑定模式文档所述:

大多数可绑定属性的默认绑定模式为OneWay,但有一些属性的默认绑定模式为TwoWay,包括以下属性:

DatePickerDate属性

EditorEntrySearchBarEntryCellText属性

ListViewIsRefreshing属性

MultiPageSelectedItem属性

PickerSelectedIndexSelectedItem属性

SliderStepperValue属性

SwitchIsToggled属性

SwitchCellOn属性

TimePickerTime属性

如果有关于控件绑定模式不确定的地方,您可以检查Maui的源代码来确定,例如,SliderValuePropertyBindingMode为TwoWay。

英文:

As the Binding mode docs say:

> Most bindable properties have a default binding mode of OneWay but
> some properties have a default binding mode of TwoWay, including the
> following:
>
> Date property of DatePicker
>
> Text property of Editor, Entry, SearchBar, and EntryCell
>
> IsRefreshing property of ListView
>
> SelectedItem property of MultiPage
>
> SelectedIndex and SelectedItem properties of Picker
>
> Value property of Slider and Stepper
>
> IsToggled property of Switch
>
> On property ofSwitchCell
>
> Time property of TimePicker

If there are control binding modes you are not sure about, you can check the source code of Maui to determine, for example, the BindingMode of ValueProperty of Slider is TwoWay.

huangapple
  • 本文由 发表于 2023年2月19日 19:36:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75499842.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定