Windows Phone 8用户按网格拖放网格 [英] Windows phone 8 drag and drop grid in grid by user
问题描述
谢谢对于任何帮助:)
尝试在网格上使用hold事件来定义要移动的对象。 (您可以操纵背景颜色以显示网格现在可以移动)。
然后使用网格的操作事件来移动控件(操作Delta和ManipulationCompleted)。操纵三角洲将给您翻译X和Y域。使用Y翻译按指定的翻译方式向上或向下移动对象。 ManipulationCompleted可以用于定义网格已完成移动。
Ie
private void holdEvent(object sender,System.Windows .Input.GestureEventArgs e)
{
//更改运动标签的背景
Grid grid =(Grid)sender;
grid.setBackground(Colors.Gray);
//应用操作事件
grid.ManipulationDelta + = new EventHandler< System.Windows.Input.ManipulationDeltaEventArgs>(GridMoving);
grid.ManipulationCompleted + = new EventHandler< ManipulationCompletedEventArgs>(GridMoved);
}
private void GridMoving(object sender,ManipulationDeltaEventArgs e)
{
//处理网格的位置
}
private void ExerciseMoved(object sender,ManipulationCompletedEventArgs e)
{
//更改背景颜色
Grid grid =(Grid)sender;
grid.setBackground(Colors.White); //在这里使用原始颜色
//从指定的网格中删除操作事件,所以它不会移动
//当用户尝试移动不同的网格。
grid.ManipulationDelta - = ExerciseMoving;
grid.ManipulationCompleted - = ExerciseMoved;
}
I have a app which has a large grid with a stack-panel and stack-viewer. Inside there are multiply grids which go down the page. Is it possible for the user to be able to drag and drop these grids so they are in a different location. They should be able to move the grid up or down a grid or multiply grids. Should there be a button in the top right corner of every grid which when the user holds down they can move that grid up or down in the stackpanel, stackviewer.
Thank you for any help :)
Trying using the hold event on the grid to define that an object is to be moved. (You could manipulate the background colour to show the grid can now be moved).
Then use the manipulation events for the grid to move the control around (Manipulation Delta and ManipulationCompleted). Manipulation delta will give you translation in both the X and Y domain. Use the Y translation to move the object up or down by the specified translation. ManipulationCompleted can then be used to define that the grid has finished being moved.
I.e
private void holdEvent(object sender, System.Windows.Input.GestureEventArgs e)
{
// Change the background of the exercise label
Grid grid = (Grid)sender;
grid.setBackground(Colors.Gray);
// Apply manipulation events
grid.ManipulationDelta += new EventHandler<System.Windows.Input.ManipulationDeltaEventArgs>(GridMoving);
grid.ManipulationCompleted += new EventHandler<ManipulationCompletedEventArgs>(GridMoved);
}
private void GridMoving(object sender, ManipulationDeltaEventArgs e)
{
// Manipulate the position of the grid here
}
private void ExerciseMoved(object sender, ManipulationCompletedEventArgs e)
{
//Change background colour back
Grid grid = (Grid)sender;
grid.setBackground(Colors.White); // Use the original colour here
// Remove the manipulation events from that specified grid, so it wont move,
// when the user trys to move a different grid.
grid.ManipulationDelta -= ExerciseMoving;
grid.ManipulationCompleted -= ExerciseMoved;
}
这篇关于Windows Phone 8用户按网格拖放网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!