UWP通过选择椭圆的笔划来改变椭圆的宽度和高度
我在UWP XAML中有一个椭圆,我想通过选择它的笔划来增加和减少它的宽度和高度。 这应该是平滑的,请建议, //XAML代码UWP通过选择椭圆的笔划来改变椭圆的宽度和高度,uwp,uwp-xaml,Uwp,Uwp Xaml,我在UWP XAML中有一个椭圆,我想通过选择它的笔划来增加和减少它的宽度和高度。 这应该是平滑的,请建议, //XAML代码 <Grid x:Name="rootGrid"> <Ellipse x:Name="DifficultyPath" Stroke="Black" StrokeDashArray="4,4" Width="250" Height="250"
<Grid x:Name="rootGrid">
<Ellipse x:Name="DifficultyPath" Stroke="Black" StrokeDashArray="4,4"
Width="250"
Height="250"
Visibility="Visible"
PointerEntered="DifficultyPath_PointerEntered"
PointerExited="DifficultyPath_PointerExited"
PointerPressed="DifficultyPath_PointerPressed"
PointerReleased="DifficultyPath_PointerReleased"
PointerMoved="DifficultyPath_PointerMoved"
/>
</Grid>
我对“通过选择椭圆的笔划来改变椭圆的宽度和高度”感到困惑,你是说当你选择整个椭圆,然后用鼠标拖动它来改变它的大小?如何选择其笔划?你能展示一些关于你目前所取得成就的代码片段,并更详细地描述你预期的行为吗?我已经更新了代码,基本上,我的逻辑是一旦用户按下笔划,我就抓住了这个点,在移动中,我找到了新的鼠标位置,并减去->现在尝试增加ellipseIt的宽度和高度听起来是可行的,您目前遇到的问题是什么?你能描述一下这种意外的行为,并提供一个简单的样本供我们测试吗?代码片段不完整,因此我们无法复制它。
private void DifficultyPath_PointerMoved(object sender, PointerRoutedEventArgs e)
{
var diffPath = e.OriginalSource as Ellipse;
Pointer ptr = e.Pointer;
if (diffPath !=null && diffPath.Name== "DifficultyPath" && ptr !=null)
{
if (ptr.PointerDeviceType == PointerDeviceType.Mouse)
{
Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(rootGrid);
if (ptrPt.Properties.IsLeftButtonPressed)
{
//Handle button press
mouseNewPoint = ptrPt.Position;
var offset = GetDistance(mouseNewPoint.X,mouseNewPoint.Y, mousePressedPoint.X, mousePressedPoint.Y);
Debug.WriteLine(offset);
DifficultyPath.Width += offset;
DifficultyPath.Height += offset;
}
}
}
e.Handled = true;
}