Pictures slideshow with pinch zoom in WP8

倾然丶 夕夏残阳落幕 提交于 2019-12-25 11:49:20

问题


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. Also, maybe there are some standard patterns for it that I missed?

UPD: Some Code

<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

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

回答1:


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/ ).

There is even a sample app where it's been used up on MSDN ( http://code.msdn.microsoft.com/wpapps/Basic-Lens-sample-359fda1b )



来源:https://stackoverflow.com/questions/23442856/pictures-slideshow-with-pinch-zoom-in-wp8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!