metro 拖动元素 元素 GIS

public sealed partial class MainPage : Page
{
// Global Transform used to change the position of the Rectangle.
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 TestRectangle_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{

}

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

}

<Page
x:Class="dragTranslationx.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:dragTranslationx"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Grid.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</Grid.ChildrenTransitions>
<Grid.Resources>
<Storyboard x:Name="downAnimation">

</Storyboard>
<Storyboard x:Name="upAnimation">

</Storyboard>
</Grid.Resources>



<Rectangle ManipulationMode="All" Width="200" Height="200" Fill="Beige" x:Name="TestRectangle" ></Rectangle>
</Grid>

</Page>

原文地址:https://www.cnblogs.com/gisbeginner/p/2690526.html