2013-04-26 21 views
0

使用默認的Windows數據透視應用程序來創建數據透視應用程序,想要在數據透視控制上添加2個按鈕,但他們繼續出現重疊在數據透視上,而不是上面。 例如下面的代碼不會產生正確的結果Windows Phone 7 - 按鈕以上的數據透視控制

<!--LayoutRoot is the root grid where all page content is placed--> 
<Grid x:Name="LayoutRoot" Background="Transparent"> 

    <Button Name ="btnFav" Content="Favourite" HorizontalAlignment="Left" Height="77" Margin="157,0,0,0" VerticalAlignment="Top" Width="158" RenderTransformOrigin="1.608,0.329" BorderBrush="#FFD49A48" Foreground="#FF007C00"/> 

    <!--Pivot Control--> 
    <controls:Pivot Name="objPivot" > 


    </controls:Pivot> 

回答

1

在網格中,控件位於行和列中。如果您不指定一行或一列,則控件將位於第一個。所以在你的情況下,按鈕和樞軸位於第一行和第一列,因此是重疊的。

只是聲明瞭兩個不同行,並把每一個控制:

<Grid x:Name="LayoutRoot" Background="Transparent"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto" /> 
     <RowDefinition /> 
    </Grid.RowDefinition> 

    <Button Grid.Row="0" Name ="btnFav" Content="Favourite" HorizontalAlignment="Left" Height="77" Margin="157,0,0,0" VerticalAlignment="Top" Width="158" RenderTransformOrigin="1.608,0.329" BorderBrush="#FFD49A48" Foreground="#FF007C00"/> 

    <!--Pivot Control--> 
    <controls:Pivot Name="objPivot" Grid.Row="1"> 

</controls:Pivot> 

請注意,我已經聲明的第一行用自動方式。這樣,它會自動調整大小,使其具有與其子控件相同的高度(在您的情況下爲按鈕)。您可以根據需要更改Height屬性的值。

+0

謝謝@KooKiz。這解決了我的問題 – 2013-04-29 08:48:53