Xaml 网架柱跨尺寸
我需要使用OnIdiom来定义网格列,但它不起作用。请参阅下面的代码。谁能告诉我我做错了什么并提出解决方案Xaml 网架柱跨尺寸,xaml,xamarin,xamarin.forms,columnspan,detection-idiom,Xaml,Xamarin,Xamarin.forms,Columnspan,Detection Idiom,我需要使用OnIdiom来定义网格列,但它不起作用。请参阅下面的代码。谁能告诉我我做错了什么并提出解决方案 <Grid.ColumnDefinitions> <ColumnDefinition> <ColumnDefinition.Width> <OnIdiom x:TypeArguments="GridLe
<Grid.ColumnDefinitions>
<ColumnDefinition>
<ColumnDefinition.Width>
<OnIdiom x:TypeArguments="GridLength" Tablet="64.9*" Phone="99.8*"/>
</ColumnDefinition.Width>
</ColumnDefinition>
<ColumnDefinition>
<ColumnDefinition.Width>
<OnIdiom x:TypeArguments="GridLength" Tablet="0.1*" Phone="0.1*"/>
</ColumnDefinition.Width>
</ColumnDefinition>
<ColumnDefinition>
<ColumnDefinition.Width>
<OnIdiom x:TypeArguments="GridLength" Tablet="35*" Phone="0.1*"/>
</ColumnDefinition.Width>
</ColumnDefinition>
这没有帮助,所以我做了:
<Grid.ColumnSpan>
<OnIdiom x:TypeArguments="x:Int32" Phone="3" Tablet="1"/>
</Grid.ColumnSpan>
这也没有帮助。x:DataType而不是x:TypeArguments对我来说很有用
override void OnSizeAllocated(double width, double height)
{
//according with height and width you can design your layouts
if (Device.Idiom == TargetIdiom.Phone)
{
// layout views vertically
}
else
{
// layout views horizontally or use different Page
}
}
<Grid.RowDefinitions>
<RowDefinition >
<RowDefinition.Height>
<OnIdiom x:DataType="GridLength" Tablet=".25*" Phone="0.075*" />
</RowDefinition.Height>
</RowDefinition>
<RowDefinition >
<RowDefinition.Height>
<OnIdiom x:DataType="GridLength" Tablet="*" Phone="0.85*" />
</RowDefinition.Height>
</RowDefinition>
<RowDefinition >
<RowDefinition.Height>
<OnIdiom x:DataType="GridLength" Tablet=".25*" Phone="0.075*" />
</RowDefinition.Height>
</RowDefinition>
</Grid.RowDefinitions>
你能解释一下什么不起作用吗?代码是否未编译?或者UI中的结果不是预期的结果?没关系。修正了。谢谢你能把你的解决方案作为一个答案贴出来,让其他人知道你做了什么来解决它吗?是的,当然……这是公认的答案@Riyas