Giter Club home page Giter Club logo

dragpage's Introduction

/********************************************************************************/
//Copyright 2013 Agustin Gimenez Bernad
//
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
/********************************************************************************/

DragPage 1.0
-------------

*What is this?

DragPage is a WinRT component which inherits from Page and allows to use drag and drop in ANY control contained inside it.

*Requirements

Visual Studio 2012
The WinRT XAML Toolkit (https://winrtxamltoolkit.codeplex.com/)

*How it works?

The basics are really simple:

	1-Add the DragPage.IsDragable property to the controls you want to drag.
	2-Add the DragPage.IsDropTarget to the controls who admit drop.
	3-Attach to the DragBegin event if necessary. This event allows to cancel a drag before it starts.
	4-Attach to the DragEnd event. The arguments hold the source and the target of the operation
	5-Done!

*Known limitations?

-Drag is limied to one object simultaneously (you cannot drag multiple items) BUT, you can drag ANY control, so you can group your controls inside a Panel and drag it (see BeginItemDrag in DragPage).
-If the dragged item has a RenderTransform applied to it, the dragged image will be incorrect.

*Why you did this?

Ok, i'm programming some Windows Store applications, and in one of them I wanted to drag and drop some images.
But Oh, Oh! in Windows Store apps, only the GridView and ListView can do this!! WTF!!!

That's really nice, so, if you want a layout which is not a ListView or GridView you can just go to sh*t without passing through the middle, or code it by yourself.

My first try was to wrap each item inside a GridView. It wasn't elegant, but it seemed to work. Notate the *seemed* word.

After coding everything and sent it to the store for certification, it was rejected because the drag and drop did not worked using touches.

Ok, nice, a property to disable drag and drop only for touches? Well Done! XD

So I enabled the "IsSwipeEnabled" (think it was) and it started to drag, but hell!! what a crap of drag!!
It only works for the perpendicular direction to the inner ScrollViewer scroll direction of the GridView/ListView.

One can think "ok, so, if I disable the ScrollViewer scrolls, it should drag in both axes, no?" WRONG!!
If the ScrollViewer horizontal scroll and vertical scroll are disabled, the drag and drop stops working, and the same happens if both are active.

So, finally I gave up and did the DragPage.

It worked so fine that I had to publish it and let anyone who needs to use it, so here it is.

Hope it helps you!

dragpage's People

Contributors

gusmanb avatar amasasi avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

amasasi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.