José
José

Reputation: 165

Different grid sizes on platforms

I have a Grid where in Windows Univesal the HeightRequest is 160, on Android and iOS it will be 100. How can I do this per platform identification inside XAML?

<ListView x:Name="List" IsRefreshing="False" IsPullToRefreshEnabled="True" BackgroundColor="#ffffff">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>          
                //-- if Grid = windows
                <Grid Padding="5" HeightRequest="160">

                //-- if Grid = ios and android
                <Grid Padding="5" HeightRequest="100">

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="90"/>
                        <ColumnDefinition Width="5"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <StackLayout HeightRequest="80" WidthRequest="80">
                    </StackLayout>
                </Grid>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

Upvotes: 0

Views: 548

Answers (1)

ColeX
ColeX

Reputation: 14475

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

Upvotes: 1

Related Questions