[UWP] [VB] [XAML] Drag&丢弃:重新排列元素 [英] [UWP][VB][XAML]Drag & Drop: Rearrange Elements
问题描述
我有一个应用程序,我希望允许用户通过拖动重新排序元素(元素在XAML中,而不是ItemsControl或其他控件中的项目)。我是拖拉的新手。 drop,所以我不熟悉DataBackage或涉及
的事件。任何帮助,将不胜感激。谢谢。
Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
< blockquote>
Nathan Sokalski,
有一个官方关于拖放样本,请参考此链接: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlDragAndDrop 。
我们可以使用 UIElement.DragEnter事件来处理拖动到UIElement的Control,当输入系统使用此元素作为目标报告基础拖动事件时,它会发生。如果我们可以使用DragEventArgs.GetPosition方法
来获取页面中Control的位置。
然后我们应该通过设置元素的位置来重新排序元素或StackPanel中的订单。
最好的问候,
Jayden Gu
I have an app in which I want to allow the user to reorder the elements by dragging (the elements are in the XAML, not items in an ItemsControl or other control). I am new to drag & drop, so I am not familiar with the DataPackage or events involved in the process. Any help would be appreciated. Thanks.
Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
Hi Nathan Sokalski,
There is an official about Drag and drop sample, please refer that in this link: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlDragAndDrop.
We can use the UIElement.DragEnter event to handle the Control that drag to the UIElement, it occurs when the input system reports an underlying drag event with this element as the target. And in the event we can use the DragEventArgs.GetPosition method to get the posotion of the Control in Page.
Then we should able to reorder the elements by set the element's position or the order in the StackPanel.
Best Regards,
Jayden Gu
这篇关于[UWP] [VB] [XAML] Drag&丢弃:重新排列元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!