OnPlatform tags not working in Xamarin formats

I am using Xamarin Studio 6.1, recently updated it to work with the Xamarin Forms project. I can't seem to get the OnPlatform tags to work. I'm trying something like this

<Grid Padding="12">
    <Grid.HeightRequest>
        <OnPlatform />
    </Grid.HeightRequest>
</Grid>

Preview breaks immediately and complains about invalid XAML: Type OnPlatform not found in xmlns="http://xamarin.com/schemas/2014/forms"

I have never seen this error before and cannot find any help on the Internet. Any ideas?

+4
source share
1 answer

This may be due to a lack of description TypeArguments. Try the following:

<Grid.HeightRequest>
    <OnPlatform x:TypeArguments="x:Double"
      iOS="15" Android="10" WinPhone="10"/>
</Grid.HeightRequest>

Update:

The syntax above is deprecated. New form:

<Grid.HeightRequest>
    <OnPlatform x:TypeArguments="x:Double">
        <On Platform="iOS" Value="15"/>
        <On Platform="Android" Value="10"/>
        <On Platform="WinPhone" Value="10"/>
    </OnPlatform>
</Grid.HeightRequest>
+8
source

Source: https://habr.com/ru/post/1655093/


All Articles