如何在 Xamarin Forms 中使用附加属性,例如 Grid.Row、AbsoluteLayout.LayoutFlags 到 OnPlatform 标记 [英] How to use attached properties such as Grid.Row, AbsoluteLayout.LayoutFlags to OnPlatform tag in Xamarin Forms
本文介绍了如何在 Xamarin Forms 中使用附加属性,例如 Grid.Row、AbsoluteLayout.LayoutFlags 到 OnPlatform 标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现在,我尝试使用以下代码
For now, I tried with below code
<StackLayout>
<StackLayout.Grid.Row>
<OnPlatform ... />
</StackLayout.Grid.Row>
</StackLayout>
还有
<StackLayout>
<Grid.Row>
<OnPlatform ... />
</Grid.Row>
</StackLayout>
没有任何效果
推荐答案
使用 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>
这篇关于如何在 Xamarin Forms 中使用附加属性,例如 Grid.Row、AbsoluteLayout.LayoutFlags 到 OnPlatform 标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文