Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Text based drag and drop in xamarin.forms

$
0
0

I have implemented text based drag and drop in Xamarin.Android, all boxes on left can be dragged and all boxes on right are drop targets.

For Xamarin.Android project i had generated dynamic Textviews and used onTouch and OnDrag events

    `public bool OnTouch(View v, MotionEvent e)
            {
                if (e.Action == MotionEventActions.Down) {              
                    ClipData data = ClipData.NewPlainText ("", "");
                    View.DragShadowBuilder shdowbuilder = new View.DragShadowBuilder (v);
                    v.StartDrag (data, shdowbuilder, v, 0);
                    oldY = e.RawY;
                    return true;
                } else {
                    if (e.Action == MotionEventActions.Cancel) {
                        if (oldY < e.RawY) {
                            scrollv.ScrollTo (0, Lmain1.Bottom);                        
                        }
                        if (oldY > e.RawY) {
                            scrollv.ScrollTo (0, Lmain1.Top);                   
                        }
                    }
                    return true;
                }
            }
            public bool OnDrag(View v, DragEvent e)
            {
                if (e.Action == DragAction.Drop) 
                {           
                    View view = (View)e.LocalState;
                    TextView dropTarget = (TextView)v;

                    TextView dropped = (TextView)view;
                    string txt = dropped.Text.ToString ();
                    dropTarget.Text=txt;
                    dropTarget.SetBackgroundColor (Android.Graphics.Color.LightBlue);
                    Object tag = dropTarget.Tag;
                    dropTarget.Tag = dropped.Tag;

                }           
                return true;
            }`

Now i want to implement same in Xamarin.Forms app, Can anyone help me how to go about doing it for ios?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>