英文:
Where to find the default binding mode of a control bindable property?
问题
无论何时处理BindableProperty,都有4种不同的绑定模式:
- TwoWay — 数据在源和目标之间双向流动
- OneWay — 数据从源到目标流动
- OneWayToSource — 数据从目标到源流动
- OneTime — 数据从源到目标流动,但仅在BindingContext更改时
根据文档所述:
> 大多数属性(如Rotation、Scale和Opacity)的默认绑定模式是OneWay。
然而,每当我阅读特定控件及其可绑定属性的文档时,我无法找到它们的默认绑定模式(例如Label TextProperty)
问题是:我如何轻松获取控件可绑定属性的默认绑定模式?
英文:
Whenever dealing with a BindableProperty, there are 4 different binding modes:
- TwoWay — data goes both ways between source and target
- OneWay — data goes from source to target
- OneWayToSource — data goes from target to source
- 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,包括以下属性:
DatePicker
的Date
属性
Editor
、Entry
、SearchBar
和EntryCell
的Text
属性
ListView
的IsRefreshing
属性
MultiPage
的SelectedItem
属性
Picker
的SelectedIndex
和SelectedItem
属性
Slider
和Stepper
的Value
属性
Switch
的IsToggled
属性
SwitchCell
的On
属性
TimePicker
的Time
属性
如果有关于控件绑定模式不确定的地方,您可以检查Maui的源代码来确定,例如,Slider的ValueProperty
的BindingMode
为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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论