问题
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.
回答1:
The ViewportControl is supported for Silverlight 8.1 apps. It is not supported for Windows Phone Runtime apps.
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;
}
See the XAML scrolling, panning, and zooming sample to demonstrate zooming with a ScrollViewer.
See Quickstart: Touch input for more info on handling manipulations.
来源:https://stackoverflow.com/questions/26154318/could-the-viewportcontrol-support-on-windows-phone-8-1