1

For now, I tried with below code

<StackLayout>
    <StackLayout.Grid.Row>
        <OnPlatform ... />
    </StackLayout.Grid.Row>
</StackLayout>

And also

<StackLayout>
    <Grid.Row>
        <OnPlatform ... />
    </Grid.Row>
</StackLayout>

Nothing works

imgen
  • 2,803
  • 7
  • 44
  • 64

3 Answers3

2

Use StaticResource

i.e:

  <AbsoluteLayout>
    <StackLayout AbsoluteLayout.LayoutBounds="{StaticResource ContainerPosition}" AbsoluteLayout.LayoutFlags="None">
      <BoxView AbsoluteLayout.LayoutBounds="{StaticResource BoxPosition}" Color="Maroon"/>
    </StackLayout>
    <AbsoluteLayout.Resources>
      <ResourceDictionary>
        <OnIdiom x:Key="BoxPosition" x:TypeArguments="Rectangle" Phone="82,26,60,46" Tablet="111,0,60,46"/>
        <OnPlatform x:Key="ContainerPosition" x:TypeArguments="Rectangle" iOS="100,100,100,100" Android="100,80,100,110" Windows="100,120,100,100"/>
      </ResourceDictionary>
    </AbsoluteLayout.Resources>
  </AbsoluteLayout>
eakgul
  • 3,658
  • 21
  • 33
1

Correct way is below

AbsoluteLayout.LayoutBounds="{OnIdiom Phone='0.4,0.5,-1,-1',Tablet='0.5,0.5,-1,-1'}"
sotmot
  • 1,256
  • 2
  • 9
  • 21
0

This answer doesn't work for me. Maybe it's a Grid issue. Error on lines Row, Column, RowSpan, ColumnSpan

<views:BaseDetailsPage.Resources>
    <ResourceDictionary>
        <system:Int32 x:Key="PlatformColSpan">
            <OnIdiom x:TypeArguments="system:Int32"
                     Phone="2"
                     Tablet="1" />
        </system:Int32>
        <system:Int32 x:Key="PlatformRowSpan">
            <OnIdiom x:TypeArguments="system:Int32"
                     Phone="1"
                     Tablet="2" />
        </system:Int32>
        <system:Int32 x:Key="CapsulesRow">
            <OnIdiom x:TypeArguments="system:Int32"
                     Phone="1"
                     Tablet="0" />
        </system:Int32>
        <system:Int32 x:Key="CapsulesCol">
            <OnIdiom x:TypeArguments="system:Int32"
                     Phone="0"
                     Tablet="1" />
        </system:Int32>
    </ResourceDictionary>
</views:BaseDetailsPage.Resources>

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <views:HomeIndicePreviewView Grid.Row="0" />
    <Grid Grid.Row="1">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Label Grid.Row="0"
               Grid.Column="0"
               Grid.RowSpan="{StaticResource PlatformRowSpan}"
               Grid.ColumnSpan="{StaticResource PlatformColSpan}"
               Text="Echos">
        </Label>
        <Label Grid.Row="{StaticResource CapsulesRow}"
               Grid.Column="{StaticResource CapsulesCol}"
               Grid.RowSpan="{StaticResource PlatformRowSpan}"
               Grid.ColumnSpan="{StaticResource PlatformColSpan}"
               Text="Capsules" />
    </Grid>
</Grid>
Sylvain Gravel
  • 259
  • 4
  • 5
  • Grid.SetRowSpan(EchosView, Resources["PlatformRowSpan"] as OnIdiom); Grid.SetColumnSpan(EchosView, Resources["PlatformColumnSpan"] as OnIdiom); Grid.SetRow(CapsulesView, Resources["CapsulesRow"] as OnIdiom); Grid.SetColumn(CapsulesView, Resources["CapsulesColumn"] as OnIdiom); Grid.SetRowSpan(CapsulesView, Resources["PlatformRowSpan"] as OnIdiom); Grid.SetColumnSpan(CapsulesView, Resources["PlatformColumnSpan"] as OnIdiom); – Sylvain Gravel Dec 12 '16 at 14:27
  • Oh, sorry, my bad, I was really trying to comment on the original message. – Sergey.quixoticaxis.Ivanov Dec 12 '16 at 14:41
  • The problem is that Xaml parsing doesn't handle attached properties in a coherent way when trying to use a proxy (OnIdiom or OnPlatform).Apparently, it works for some properties by putting the proxy in resources and then referencing those but it doesn't seem to work for Grid attached properties, which is what my answer is saying. – Sylvain Gravel Dec 12 '16 at 15:21
  • Not sure why the above is an accepted answer, I can't get it to work for AbsoluteLayout bounds either... – Sylvain Gravel Dec 12 '16 at 18:49