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