从这篇文章我开始知道存在一些平台改进来实现捏合和缩放功能.通过使用这个新方法(ManipulationDeltaEventArgs.PinchManipulation)我如何在Windows Phone中实现捏缩放功能.
除此之外,我还需要为图像控件实现滚动功能.在我目前的实现中,我使用Toolkit(手势监听器)进行捏合和缩放功能以及滚动查看器,现在看起来既滚动又捏合事件重叠,因此会产生糟糕的用户体验.
任何人都可以帮助我在我的应用程序中解决这个问题.我正在寻找一些帮助我实现功能的代码示例.
我不希望得到Multi touch行为(codeplex)作为答案.在项目中使用的组件已经很老了,我听说他们中的许多人因此而面临市场提交的问题.
silverlight-4.0 windows-phone-7 windows-phone-7.1 windows-phone-8
我将图像控件放在滚动查看器中,就像tnis一样:
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" >
<Image Source="/Test/1.jpg" Width="320">
<Image.RenderTransform>
<CompositeTransform ScaleX="{Binding Path=Value, ElementName=slider}"/>
</Image.RenderTransform>
</Image>
</ScrollViewer>
Run Code Online (Sandbox Code Playgroud)
正如代码所示,我添加了一个滑块来控制图像的Compositetransform,但是当我改变滑块的值时,什么也没发生?
我还尝试在图像上附加缩放和平移行为(取决于工具包),不幸的是,我可以上下滚动,但我无法放大/缩小图像.似乎Scrollviewer阻止了捏合操纵.
我们知道,Scrollviewer控件在WPF中有一个"ZoomMode"属性,但在Windows Phone中已弃用.那么我怎样才能实现iamge缩放滚动查看器,有人能给我一个帮助吗?
我使用此代码获得全屏图像:
<phone:PhoneApplicationPage
x:Class="solution.FullScreenViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<Image Name="img" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"Stretch="Uniform"/>
</phone:PhoneApplicationPage>
Run Code Online (Sandbox Code Playgroud)
这只是一个更大项目的一部分.我想在点击它之后实现te feture以全屏打开图像,所以我用另一个图像制作了另一个页面.我正在使用以下代码从C#加载图像:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
string context = this.NavigationContext.QueryString["context"];
img.Source = new BitmapImage(new Uri(context, UriKind.RelativeOrAbsolute));
base.OnNavigatedTo(e);
}
Run Code Online (Sandbox Code Playgroud)
现在我想添加一个缩放图片的选项,但我不知道如何.我也尝试了谷歌,但我发现的唯一一件事是在ScroolViewer中使用ZoomMode,这对我不起作用(它说成员ZoomMode无法识别).
还有其他解决方案可以放大吗?