我有一个带有FlipView的Windows Phone 8.1应用程序。每个FlipView项目代表一个杂志页面(PDF页面呈现为具有一些叠加的位图)。
我需要启用捏合来缩放所有页面。我的FlipView ItemTemplate看起来像这样
<DataTemplate
x:Key="SinglePageTemplate">
<ScrollViewer
ZoomMode="Enabled">
<Grid>
<ProgressRing
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsActive="{Binding IsRendered, Converter={StaticResource BooleanNegateConverter}}" />
<Image
Source="{Binding Bitmap}"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
</Image>
</Grid>
</ScrollViewer>
问题在于,当我缩小页面并尝试将其向右移动时,它总是“跳”回到左侧。
以下是显示问题的视频:https://dl.dropboxusercontent.com/u/73642/fv.avi
任何想法为什么以及如何解决它?
答案 0 :(得分:0)
在您的滚动查看器中,您必须手动启用scrollbarvisiblity和模式
<ScrollViewer ZoomMode="Enabled"
HorizontalScrollBarVisibility="Visible"
VerticalScrollBarVisibility="Visible"
HorizontalScrollMode="Enabled"
VerticalScrollMode="Enabled">
<Grid>
<ProgressRing
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsActive="{Binding IsRendered, Converter={StaticResource BooleanNegateConverter}}" />
<Image
Source="{Binding Bitmap}"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
</Image>
</Grid>
</ScrollViewer>
您也可以选择设置Max / MinZoomFactor以防止重叠
答案 1 :(得分:0)
我遇到了同样的问题。我通过使用附加行为并设置HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible"
以下是用于附加行为的代码
public class PanAndZoomBehavior : Behavior<ScrollViewer>
{
protected override void OnAttached()
{
base.OnAttached();
Window.Current.SizeChanged += OnSizeChanged;
SetElementSize();
}
protected override void OnDetaching()
{
base.OnDetaching();
Window.Current.SizeChanged -= OnSizeChanged;
}
private void OnSizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
{
SetElementSize();
}
private void SetElementSize()
{
AssociatedObject.Width = Window.Current.Bounds.Width;
AssociatedObject.Height = Window.Current.Bounds.Height;
if (AssociatedObject.Content != null)
{
FrameworkElement element = (FrameworkElement)AssociatedObject.Content;
element.Width = Window.Current.Bounds.Width;
element.Height = Window.Current.Bounds.Height;
}
}
}
将此行为应用于ScrollViewer