这是复制我的问题的一个例子
<FlipView>
<FlipView.Resources>
<Style TargetType="FlipViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="FlipViewItem">
<ScrollViewer HorizontalAlignment="Center" VerticalAlignment="Center"
HorizontalContentAlignment="Center" VerticalContentAlignment="Center" >
<ContentPresenter />
</ScrollViewer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</FlipView.Resources>
<Rectangle Width="1366" Height="768" >
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0,0" StartPoint="1,0">
<GradientStop Color="White"/>
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="White" Offset="0.487"/>
<GradientStop Color="Black" Offset="0.44"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</FlipView>
更改后,scrollviewer的horizental偏移量将自动设置为0。 我认为这总是发生在与flipview的滚动方向相同的方向上。 但是,如何解决?
答案 0 :(得分:1)
默认ScrollViewer
仅在需要时滚动,并且您的矩形小于ScrollViewer。另外 - 你只有一个项目。您可以尝试设置其样式:Style="{StaticResource HorizontalScrollViewerStyle}"
。如下:
<Page
x:Class="App113.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App113"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid
Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Grid.Resources>
<LinearGradientBrush
x:Key="LibearBrush"
EndPoint="0,0"
StartPoint="1,1">
<GradientStop
Color="White" />
<GradientStop
Color="Black"
Offset="1" />
<GradientStop
Color="White"
Offset="0.487" />
<GradientStop
Color="Black"
Offset="0.44" />
</LinearGradientBrush>
</Grid.Resources>
<FlipView>
<FlipView.Resources>
<Style
TargetType="FlipViewItem">
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="FlipViewItem">
<!--Style="{StaticResource VerticalScrollViewerStyle}" is the standard alternative-->
<ScrollViewer
Style="{StaticResource HorizontalScrollViewerStyle}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
<ContentPresenter />
</ScrollViewer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</FlipView.Resources>
<Rectangle
Width="2366"
Height="1768"
Fill="{StaticResource LibearBrush}" />
<Rectangle
Width="2366"
Height="1768"
Fill="{StaticResource LibearBrush}" />
<Rectangle
Width="2366"
Height="1768"
Fill="{StaticResource LibearBrush}" />
</FlipView>
</Grid>
</Page>