在XAML中,PivotItems在Windows Phone上没有完整的屏幕宽度。这是一种很好的行为和设计,但对于单个图像,我希望它能够填满整个屏幕宽度。
这可以完成吗?
答案 0 :(得分:8)
根本原因是默认PivotItemMargin
设置为12,0,12,0
。我们可以在generic.xaml中找到该设置。
所以我们需要做的是覆盖App.xaml中的设置。就像这样:
<Thickness x:Key="PivotItemMargin">0</Thickness>
答案 1 :(得分:5)
这是解决方案,具有负余量
<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
答案 2 :(得分:0)
请使用此代码,
<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>
正在工作.. 我已经实施了......:)