本文介绍了Windows Phone 8用户按网格拖放网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它有一个大型网格,堆栈面板和堆栈查看器。里面有多个网格向下翻页。用户可以将这些网格拖放到不同的位置。他们应该能够向上或向下移动网格或乘以网格。如果每个网格的右上角都有一个按钮,当用户按住它们时,它们可以在堆叠面板中将该网格向上或向下移动,stackviewer。



谢谢对于任何帮助:)

解决方案

尝试在网格上使用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用户按网格拖放网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 05:16