[英]Pictures slideshow with pinch zoom in WP8
I am trying to make application with classic pictures view like in photo hub or any standard picture application on any mobile device. 我正在尝试使应用程序具有经典的图片视图,例如在照片中心或任何移动设备上的任何标准图片应用程序中。 So far I began to use FlipView from Kinnara's toolkit fork and CompositeTransform for pinchzooming, but I don't understand how to align picture to the center of the screen (VerticalAlignment=Center seems to not working as a property of Image inside DataTemplate) and I don't understand how to make zoomed pictures not visible in background when viewing neighbor picture.
到目前为止,我开始使用Kinnara的工具包fork中的FlipView和CompositeTransform进行捏缩放,但是我不了解如何将图片与屏幕的中心对齐(VerticalAlignment = Center似乎不能作为DataTemplate中Image的属性)。不了解在查看邻居图片时如何使放大的图片在背景中不可见。 Also, maybe there are some standard patterns for it that I missed?
另外,也许我错过了一些标准模式?
UPD: Some Code UPD:一些代码
<toolkit:FlipView x:Name="FlipView"
d:DataContext="{d:DesignInstance viewModels:PostsViewModel}"
ItemsSource="{Binding Pictures}">
<toolkit:FlipView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<ProgressBar Value="{Binding DownloadProgress}"
Maximum="100"
Minimum="1"
IsEnabled="{Binding IsLoading}" />
<Image x:Name="PostImage"
Source="{Binding Sample}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stretch="UniformToFill"
ManipulationDelta="Image_OnManipulationDelta">
<Image.RenderTransform>
<CompositeTransform />
</Image.RenderTransform>
</Image>
</StackPanel>
</DataTemplate>
</toolkit:FlipView.ItemTemplate>
</toolkit:FlipView>
UPD2: Pinchzooming code UPD2:Pinchzooming代码
private void Image_OnManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
if (e.PinchManipulation != null)
{
var transform = (CompositeTransform)((Image) sender).RenderTransform;
// Scale Manipulation
transform.ScaleX = e.PinchManipulation.CumulativeScale;
transform.ScaleY = e.PinchManipulation.CumulativeScale;
// Translate manipulation
var originalCenter = e.PinchManipulation.Original.Center;
var newCenter = e.PinchManipulation.Current.Center;
transform.TranslateX = newCenter.X - originalCenter.X;
transform.TranslateY = newCenter.Y - originalCenter.Y;
// end
e.Handled = true;
}
}
If you want the more OS like look and feel ( like how images are shown in the pictures lib ), take a look at the nuget called Windows Phone Media Viewer ( https://www.nuget.org/packages/PhoneMediaViewer/ ). 如果您想要更多的操作系统,例如外观和风格(如图片库中图片的显示方式),请查看名为Windows Phone Media Viewer的nuget( https://www.nuget.org/packages/PhoneMediaViewer/ )。
There is even a sample app where it's been used up on MSDN ( http://code.msdn.microsoft.com/wpapps/Basic-Lens-sample-359fda1b ) 甚至有一个示例应用程序已在MSDN上用完( http://code.msdn.microsoft.com/wpapps/Basic-Lens-sample-359fda1b )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.