0

这是重现我的问题的示例

<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>

滚动查看器的水平偏移量将在您更改后自动设置回 0。我认为这总是发生在与flipview的滚动方向相同的方向上。但是,如何解决?

4

1 回答 1

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>
于 2013-02-13T18:38:24.173 回答