Implementing DragStarted DragDelta events in windows 8 / WinRT -
how can attach dragstarted
dragdelta
events grid in windows 8 / winrt
. did same in windows phone gestureservice.getgesturelistener()
method. tried replace code manipulationstarted & manipulationdelta events in windows 8. result not same. in windows phone single drag enters dragdelta events 2 or more times. in other hand in windows 8, in manupulationdelta event fires once similar drag operation.
yeah, think know want.
let's have xaml this:
<grid margin="50"> <grid.columndefinitions> <columndefinition /> <columndefinition /> </grid.columndefinitions> <grid.rowdefinitions> <rowdefinition /> <rowdefinition /> </grid.rowdefinitions> <rectangle fill="blue" x:name="myrect" /> </grid>
you want move rectangle around grid
dragging it.
just use code:
public mainpage() { this.initializecomponent(); myrect.manipulationmode = manipulationmodes.translatex | manipulationmodes.translatey; myrect.manipulationdelta += rectangle_manipulationdelta; myrect.manipulationcompleted += rectangle_manipulationcompleted; } private void rectangle_manipulationdelta(object sender, manipulationdeltaroutedeventargs e) { var _rectangle = sender windows.ui.xaml.shapes.rectangle; var _transform = (_rectangle.rendertransform = (_rectangle.rendertransform translatetransform) ?? new translatetransform()) translatetransform; _transform.x += e.delta.translation.x; _transform.y += e.delta.translation.y; } private void rectangle_manipulationcompleted(object sender, manipulationcompletedroutedeventargs e) { var _rectangle = sender windows.ui.xaml.shapes.rectangle; _rectangle.rendertransform = null; var _column = system.convert.toint16(_rectangle.getvalue(grid.columnproperty)); if (_column <= 0 && e.cumulative.translation.x > _rectangle.rendersize.width * .5) _rectangle.setvalue(grid.columnproperty, 1); else if (_column == 1 && e.cumulative.translation.x < _rectangle.rendersize.width * -.5) _rectangle.setvalue(grid.columnproperty, 0); var _row = system.convert.toint16(_rectangle.getvalue(grid.rowproperty)); if (_row <= 0 && e.cumulative.translation.y > _rectangle.rendersize.height * .5) _rectangle.setvalue(grid.rowproperty, 1); else if (_row == 1 && e.cumulative.translation.y < _rectangle.rendersize.height * -.5) _rectangle.setvalue(grid.rowproperty, 0); }
for this:
hope i'm close! best of luck!
Comments
Post a Comment