<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>
so I have picker and I want to bind its Title to ThemePickerTitle property. It works well if I write it as inline attrubute. But I dont want to have title on windows. So I write OnPlatform to have it only on Ios and Droid, but now it does compile.
The Xaml you pasted suppose that the OnPlatform
object is the target of the Binding to string, and then the OnPlatform returns the right string
depending on the Platform.
Unfortunately, that doesn't work because OnPlatform
is not a BindableObject
and can't be the target of a Binding
.
What make sense, is using this 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>
It means that the OnPlatform
returns the right Binding (without evaluating it) depending on the platform. As of today (2017-01-24), this does not work in Xamarin.Forms, but the patch to fix that is ready and will land in one of the next version: https://github.com/xamarin/Xamarin.Forms/pull/709.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With