椭圆位置根据网格布局

时间:2015-03-17 00:05:46

标签: c# xaml responsive-design windows-phone-8.1 ellipse

我面对一些元素'在我的wp 8.1 app(XAML / C#)中定位问题。我已经读到要创建一个灵活的布局,我应该使用网格控件。 好吧,这是我在页面元素中的XAML:

<Grid  Style="{StaticResource LayoutGridCreateProfilStyle}">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <Rectangle Grid.Row="0" Height="60" Fill="#F3A8E4F9" ></Rectangle>
    <Rectangle Grid.Row="1" Height="40" Fill="Gray"></Rectangle>
    <ListBox Grid.Row="2" Height="420" Background="Transparent"/>
    <Canvas Grid.Row="3">
        <Ellipse Height="100" Margin="0,0,0,0" Width="100" Fill="Black" Canvas.Left="152" Canvas.Top="10"></Ellipse>
    </Canvas>

</Grid>

在XAML设计师中,我实际上看到了我想要的内容,如下所示:

Designer Picture

以下是我在诺基亚Lumia 925上的样子:

Lumia 925 Picture

正如您所看到的,椭圆被切割,我真的无法弄清楚如何放置它应该是实际出现在设计器视图中。 也许有人可以帮助我吗?

提前致谢!

1 个答案:

答案 0 :(得分:2)

问题是您的高度不足以显示网格的所有元素。前三行占用540像素的累积高度。如果运行时高度为640,那么您的网格的最后一行只剩下100个。

但是你的椭圆偏离了画布顶部10个像素,所以它需要总共110(10偏移+ 100像素椭圆高度)才能完全显示。如果你的最后一行的空间小于110像素那么它将被截断,实际上似乎是。