Jay Kannan Jay Kannan - 2 months ago 33
C# Question

OnPlatform tags not working in Xamarin Forms

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

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


The previewer immediately breaks and complains Invalid XAML: Type
OnPlatform not found in xmlns="http://xamarin.com/schemas/2014/forms"


I've never seen this error before and can't find any help online. Any ideas?

Answer

it might because of not specifiying TypeArgument. Try this:

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