c# - 如何使用户能够在 Windows Store 8 中移动屏幕图像?

标签 c# .net windows-8 windows-runtime

我有一个关于 Windows Store 8 应用程序的简单直接问题。

假设我的屏幕上有一张带有 table 的图片。当用户按下“编辑”按钮时,他现在应该能够将屏幕上的图片移动到所需的位置,直到按下“完成”为止。

我需要使用哪个类来实现它?另外,如果有一个简单的 C# 代码示例就好了。

最佳答案

您需要处理 ManipulationDelta 事件。请参阅this page有关如何使用它的一些示例。

示例... XAML

<Rectangle Name="TestRectangle" Width="200" Height="200" Fill="Blue" ManipulationMode="All"/>

C#

private TranslateTransform dragTranslation;

// Constructor
public MainPage()
{
    InitializeComponent();

    // Add handler for the ManipulationDelta event
    TestRectangle.ManipulationDelta += Drag_ManipulationDelta;
    dragTranslation = new TranslateTransform();
    TestRectangle.RenderTransform = this.dragTranslation;
}

void Drag_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
    // Move the rectangle.
    dragTranslation.X += e.Delta.Translation.X;
    dragTranslation.Y += e.Delta.Translation.Y;
}

关于c# - 如何使用户能够在 Windows Store 8 中移动屏幕图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14022085/

相关文章:

c# - IdentityServer4 用户的声明未包含在 JWT 中且未发送到 Web Api

c# - 在代码中设置边距属性

c# - 分析为什么 WCF 比 WSE webservice 慢很多

c# - 如何在 SQLite、C# 和 Windows 8 中链接表?

git - 为 Windows 8 上的 GIT 生成 SSH key

c# - 我可以内联指定我的显式类型比较器吗?

c# - 尝试反序列化对象时出现 "Exception has been thrown by the target of an invocation."

c# - 我应该使用哪个 ORM 而不是 Linq to Sql?

.net - XUnit 类似切面的功能

C++/CX - 我需要将 Platform::String 传递到采用 const char* 的方法中?