Xamarin forms: What is the correct format of RowDefinition height OnIdiom property?

753 views Asked by At

I have 2 rows inside a grid, for the first row has a fixed size. I am trying to apply the OnIdiom feature here. Tried like below:

<Grid.RowDefinitions>
    <RowDefinition>
        <RowDefinition.Height>
            <OnIdiom x:TypeArguments="x:Double">
                <OnIdiom.Phone>30</OnIdiom.Phone>
                <OnIdiom.Tablet>60</OnIdiom.Tablet>
            </OnIdiom>
        </RowDefinition.Height>
    </RowDefinition>
    <RowDefinition Height="auto"/>
</Grid.RowDefinitions>

But getting following error on error list:

No property, bindable property, or event found for 'Height', or mismatching type between value and property.

What is the correct format of RowDefinition height OnIdiom property?

2

There are 2 answers

0
mshwf On BEST ANSWER

You can use the OnIdiom markup extension:

<RowDefinition Height="{OnIdiom Phone=30, Tablet=60}"/>
0
Chetan Rawat On
<Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="{OnIdiom Phone=30, Tablet=60}" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <StackLayout
            Grid.Row="0"
            BackgroundColor="Blue"
            HorizontalOptions="FillAndExpand"
            VerticalOptions="FillAndExpand" />
    </Grid>