Windows Phone 8.1 是否支持 ViewportControl? [英] Could the ViewportControl support on windows phone 8.1?

查看:52
本文介绍了Windows Phone 8.1 是否支持 ViewportControl?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我想放大或缩小列表视图上的图片.人们向我分享了这些问题,但它使用了 Windows Phone 8.1 不支持的 ViewportControl.

Now, I want zoom in or out the picture on listviews. The people had share to me that these question but It use ViewportControl that windows phone 8.1 is not support.

推荐答案

ViewportControl 支持 Silverlight 8.1 应用程序.Windows Phone 运行时应用不支持它.

The ViewportControl is supported for Silverlight 8.1 apps. It is not supported for Windows Phone Runtime apps.

您可以使用 ScrollViewer 来放大或缩小图片:

You can use a ScrollViewer to allow a picture to zoom in or out:

<ScrollViewer x:Name="scrollViewer" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
              VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" 
              ZoomMode="Enabled" MinZoomFactor="0.7">
    <Grid Height="200" Width="300">
        <Image AutomationProperties.Name="Cute kitten picture" Source="Assets/gracie.jpg" Stretch="Uniform" HorizontalAlignment="Center" VerticalAlignment="Center"/>
    </Grid>
</ScrollViewer>

或者您可以处理操作事件直接缩放图片.

Or you can handle manipulation events to zoom the picture directly.

<Image AutomationProperties.Name="Cute kitten picture" Source="Assets/gracie.jpg" 
       Stretch="Uniform"
       ManipulationMode="Scale"
       ManipulationDelta="Image_ManipulationDelta" 
       RenderTransformOrigin="0.5,0.5">
    <Image.RenderTransform>
        <CompositeTransform />
    </Image.RenderTransform>
</Image>

C#

double minScale = 0.7;
private void Image_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
    Image img = sender as Image;
    CompositeTransform ct = img.RenderTransform as CompositeTransform;

    ct.ScaleX *= e.Delta.Scale;
    ct.ScaleY *= e.Delta.Scale;

    if (ct.ScaleX < minScale) ct.ScaleX = minScale;
    if (ct.ScaleY < minScale) ct.ScaleY = minScale;
}

请参阅 XAML 滚动、平移和缩放示例 演示使用 ScrollViewer 进行缩放.

See the XAML scrolling, panning, and zooming sample to demonstrate zooming with a ScrollViewer.

请参阅快速入门:触摸输入,了解有关处理操作的更多信息.

See Quickstart: Touch input for more info on handling manipulations.

这篇关于Windows Phone 8.1 是否支持 ViewportControl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆