Xaml 如何获取数据透视项的全宽

Xaml 如何获取数据透视项的全宽,xaml,windows-phone,pivotviewer,Xaml,Windows Phone,Pivotviewer,在XAML中,数据透视项在Windows Phone上没有全屏幕宽度。这是良好的行为和设计,但对于一个单一的图像,我希望它填补整个屏幕宽度 这可以实现吗?请使用此代码 <phone:PhoneApplicationPage x:Class="NikhilSApp.DemoExample" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.c

在XAML中,数据透视项在Windows Phone上没有全屏幕宽度。这是良好的行为和设计,但对于一个单一的图像,我希望它填补整个屏幕宽度

这可以实现吗?

请使用此代码

<phone:PhoneApplicationPage 
x:Class="NikhilSApp.DemoExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"     
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait"  Orientation="Portrait"
shell:SystemTray.IsVisible="False">

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

    // You can specify the width here....
    <controls:Pivot Height="800" Width="480">
        <!--Pivot item one-->
        <controls:PivotItem Height="800" Margin="0,-130,0,0">
            <Grid Name="GridMediaQuestion">
                <Image HorizontalAlignment="Center" Source="Images/Guess.png" Margin="10,10,10,10" Name="imgReceived" Stretch="Fill" VerticalAlignment="Center" Height="790" Width="470" />
            </Grid>
        </controls:PivotItem>

        <!--Pivot item two-->
        <controls:PivotItem Height="800" >
            <Grid x:Name="GridPivot2" Background="#ffffc0">
                 // Place Your Second pivot's  Content here
             </Grid>
        </controls:PivotItem>
    </controls:Pivot>
</Grid>

//您可以在此处指定宽度。。。。
//将第二个轴心的内容放在此处
它正在工作。。
我已经实现了…:)

这是一个解决方案,具有负边界

<controls:Pivot>
    <controls:PivotItem Margin="-10,0,-10,0">
        <Grid />
    </controls:PivotItem>

    <controls:PivotItem Margin="-10,0,-10,0">
        <Grid />
    </controls:PivotItem>
</controls:Pivot>


当然,您也可以使用常规透视,只将图像边距设置为-10,0,-10,0

根本原因是默认的
PivotItemMargin
设置为
12,0,12,0
。我们可以在generic.xaml中找到设置

因此,我们需要做的是覆盖App.xaml中的设置。就像这样:

0

您尝试过使用边距吗?是的,我已经将所有内容设置为margin=“0”,从轴到网格,所有内容。发布一些xaml代码,这将更容易帮助您。您也可以仅指定一个轴项目的宽度。但根据本页,有多个分辨率可用。将其设置为480宽度并不能在每个设备上提供全宽?然后可以从后端设置它,如Pivot1.VerticalAlignment=System.Windows.VerticalAlignment.Stretch;Pivot1.HorizontalAlignment=System.Windows.HorizontalAlignment.Stretch;设置宽度没有帮助,因为有来自某个地方的边距。我试着将宽度设置为1000,但它的左边仍然有一个边距。也许WPF或RT的工作原理不同,但在Windows Phone中却不起作用。这才是真正的答案。负利润率是错误的做法。这个答案是在很久以后添加的,但我完全同意!标记为答案!有关覆盖模板的信息,请参见下文。负利润率是一种糟糕的做法。