简体   繁体   English

网格列的OnIdiom

[英]OnIdiom for Grid columnspan

I need to use OnIdiom for grid column definition, but it isn't working. 我需要使用OnIdiom进行网格列定义,但是它不起作用。 See my code below. 请参阅下面的代码。 Can anyone tell me what I am doing wrong and suggest a solution? 谁能告诉我我在做什么错并提出解决方案?

 <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>

This does not help, so I did: 这没有帮助,所以我做了:

<Grid.ColumnSpan>
       <OnIdiom x:TypeArguments="x:Int32" Phone="3" Tablet="1"/>
</Grid.ColumnSpan>

This also not helps. 这也无济于事。

x:DataType instead of x:TypeArguments works for me.. x:DataType而不是x:TypeArguments对我有用。

<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>
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
     }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM