[英]Image in a ScrollViewer in Windows Phone 8.1
I have a FlipView which shows the pages of a leaflet as the user swipes through it. 我有一个FlipView,当用户在其中浏览传单时会显示传单的页面。 I want the user to be able to zoom in a page.
我希望用户能够放大页面。 What I found so far is that if I wrap my Image inside a ScrollViewer and set ZoomMode = Enabled , the user can zoom.
到目前为止,我发现如果将Image包裹在ScrollViewer中并设置ZoomMode = Enabled ,则用户可以缩放。 The strange thing is that if I zoom in the right side of the page, it automatically goes back to the left side after I lift up my fingers from the screen.
奇怪的是,如果我放大页面的右侧,当我从屏幕上抬起手指时,它会自动返回到左侧。 Any idea how to solve this issue?
任何想法如何解决这个问题?
XAML: XAML:
<Grid Name="grRoot">
<FlipView x:Name="flipView1"
BorderBrush="Black"
ItemsSource="{Binding}">
<FlipView.ItemTemplate>
<DataTemplate>
<ScrollViewer ZoomMode="Enabled" MinZoomFactor="1">
<Image Source="{Binding url_dotcom}"
Stretch="Fill"
Holding="imgHolding"/>
</ScrollViewer>
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
</Grid>
Setting the FlipView's width and height: 设置FlipView的宽度和高度:
flipView1.Width = Window.Current.Bounds.Width;
flipView1.Height = Window.Current.Bounds.Height;
Try something like this: 尝试这样的事情:
<Grid Name="grRoot">
<FlipView x:Name="flipView1"
BorderBrush="Black"
ItemsSource="{Binding}">
<FlipView.ItemTemplate>
<DataTemplate>
<ScrollViewer ZoomMode="Enabled" MinZoomFactor="1"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<Image Source="{Binding url_dotcom}"
Stretch="Fill"
Holding="imgHolding"
MaxWidth="{Binding ElementName=YourPage, Path=DataContext.Width}"
MaxHeight="{Binding ElementName=YourPage, Path=DataContext.Height}"/>
</ScrollViewer>
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
</Grid>
There are 2 important changes here: 这里有2个重要更改:
EDIT: More info in my blog post Why is my zoomable ScrollViewer snapping the image to the left? 编辑:我的博客文章中的更多信息为什么我的可缩放ScrollViewer将图像捕捉到左侧?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.