Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用C#和Xaml实现基于触摸的旋转_C#_Wpf_Xaml_Windows Phone 8 - Fatal编程技术网

使用C#和Xaml实现基于触摸的旋转

使用C#和Xaml实现基于触摸的旋转,c#,wpf,xaml,windows-phone-8,C#,Wpf,Xaml,Windows Phone 8,我正在尝试旋转一个轮盘赌图像 这是我的xaml <phone:PhoneApplicationPage x:Class="roll.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:Microsoft.Phone.Contro

我正在尝试旋转一个轮盘赌图像

这是我的xaml

 <phone:PhoneApplicationPage
x:Class="roll.MainPage"
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"
xmlns:local="clr-namespace:System.Windows;assembly=roll"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">


<Grid>



    <TextBlock Text=" One Finger Rotation"
                   FontSize="34"
                   TextAlignment="Center"
                   Margin="64,54,31.791,668"
                   Foreground="Yellow" />

        <Image x:Name="Right"
               Margin="64,170,31.791,141" 
               Source="Roulette.png"

             ManipulationMode="TranslateX,TranslateY,TranslateInertia"
               ManipulationDelta="Right_ManipulationDelta"
               ImageOpened="Image_Opened" >

            <Image.RenderTransform>
                <RotateTransform x:Name="RightRotateTransform" />
            </Image.RenderTransform>
        </Image>


</Grid>
在xaml中,我发现行操作mode=“TranslateX,TranslateY,TranslateInertia”中存在错误 这意味着操纵模式无法识别或无法访问

在c#中,在 使用Windows.UI.Xaml.Controls; 使用Windows.UI.Xaml.Media; 使用System.Xaml.Object; 该错误表示命名空间Windows.UI中不存在Xaml

另一个错误是操纵DeltaroutedEventArgs和旋转变换

请试着帮助我 提前谢谢

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using roll.Resources;
using Windows.System;
using Windows.UI.Input;
using System.Windows.Media.Animation;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
 using System.Xaml.Object;         


  namespace roll
{


public partial class MainPage : PhoneApplicationPage
{
    // Constructor
    public MainPage()
    {
        InitializeComponent();


    }


    private void Image_Opened(object sender, Windows.UI.Xaml.RoutedEventArgs e)
    {
        Image img = sender as Image;
        RotateTransform rt = img.RenderTransform as RotateTransform;
        rt.CenterX = img.ActualWidth / 2;
        rt.CenterY = img.ActualHeight / 2;
    }

    private void Right_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
    {


        var x = this.RightRotateTransform.CenterX - e.Position.X;
        var y = this.RightRotateTransform.CenterY - e.Position.Y;

        double a1 = Math.Atan(y / x);
        double a2 = Math.Atan((e.Delta.Translation.Y - y) / (x - e.Delta.Translation.X));

        this.RightRotateTransform.Angle += a1 - a2;
    }



}
 }