mis*_*iga 3 c# xaml binding xamarin xamarin.forms
<cv:BindableComboBox ItemsSource="{Binding Themes}" SelectedValue="{Binding SelectedTheme}">
<cv:BindableComboBox.Title>
<OnPlatform x:TypeArguments="x:String"
iOS="{Binding ThemePickerTitle}"
Android="{Binding ThemePickerTitle}"/>
</cv:BindableComboBox.Title>
</cv:BindableComboBox>
Run Code Online (Sandbox Code Playgroud)
所以我有选择器,我想将其Title绑定到ThemePickerTitle属性。如果我将其写为inline attrubute,则效果很好。但是我不想在Windows上有标题。因此,我编写OnPlatform使其仅在Ios和Droid上具有,但现在可以编译了。
您粘贴的Xaml假定该OnPlatform对象是Binding to string的目标,然后OnPlatform返回正确的string根据平台。
不幸的是,这是行不通的,因为OnPlatform它不是BindableObject并且不能成为a的目标Binding。
有意义的是使用此Xaml:
<cv:BindableComboBox ItemsSource="{Binding Themes}" SelectedValue="{Binding SelectedTheme}">
<cv:BindableComboBox.Title>
<OnPlatform x:TypeArguments="BindingBase"
iOS="{Binding ThemePickerTitle}"
Android="{Binding ThemePickerTitle}"/>
</cv:BindableComboBox.Title>
</cv:BindableComboBox>
Run Code Online (Sandbox Code Playgroud)
这意味着OnPlatform根据平台返回正确的Binding(不对其进行评估)。截止到今天(2017-01-24),这在Xamarin.Forms中不起作用,但已修复的补丁已发布,将在下一版本中发布:https : //github.com/xamarin/Xamarin。表格/拉/ 709。
| 归档时间: |
|
| 查看次数: |
1690 次 |
| 最近记录: |