uwp 移动控件 ManipulationDelta
<UserControl
x:Class="TestCutPic.CutItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestCutPic"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
ManipulationMode="All"
mc:Ignorable="d" Height="103.85" Width="133.131" ManipulationDelta="UserControl_ManipulationDelta" ManipulationStarted="UserControl_ManipulationStarted"
RenderTransformOrigin="0.5,0.5"
>
<UserControl.RenderTransform>
<CompositeTransform x:Name="ct" TranslateX="0"/>
</UserControl.RenderTransform>
<Grid Background="Gray" >
</Grid>
</UserControl>
Point P = new Point();
private void UserControl_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
P = e.Position;
}
private void UserControl_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
ct.TranslateX += e.Position.X-P.X;
ct.TranslateY += e.Position.Y-P.Y;
//控制在一定范围内
if (ct.TranslateX > 500) {
ct.TranslateX = 500;
}
if (ct.TranslateY > 400)
{
ct.TranslateY = 400;
}
//--------------------
if (ct.TranslateX <- 20)
{
ct.TranslateX = -2;
}
if (ct.TranslateY < -50)
{
ct.TranslateY = -50;
}
}
}
fffffffffffffffff
test red font.