目前,我尝试使用以下代码
<StackLayout>
<StackLayout.Grid.Row>
<OnPlatform ... />
</StackLayout.Grid.Row>
</StackLayout>
还
<StackLayout>
<Grid.Row>
<OnPlatform ... />
</Grid.Row>
</StackLayout>
没有任何作用
答案 0 :(得分:2)
使用StaticResource
即:
<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>
答案 1 :(得分:1)
正确方法如下
AbsoluteLayout.LayoutBounds="{OnIdiom Phone='0.4,0.5,-1,-1',Tablet='0.5,0.5,-1,-1'}"
答案 2 :(得分:0)
这个答案对我不起作用。也许这是一个网格问题。行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>