locked
Delete Item sliding it out of the GridView (as closing a app in android 4.x) RRS feed

  • Question

  • Hi,

    I have a User Control containing a GridView, which is filled by ErrorMessages.

    I want the user to swipe the errors out of the GridView to delete them.

    (equivalent to killing apps in android 4.x)

    I tried "dragging" the item, but that didn't work. Is there any other way to achieve my aim?

    I appreciate every help i can get.

    Regards,

    T.Korb

    Wednesday, September 4, 2013 11:58 PM

Answers

  • I'd investigate the following:

    IsSwipeEnabled property (I'm not sure if this is detecting a swipe on an item in the gridview or on the gridview itself)

    All the Drag* actions available (these may provide a built-in swipe gesture or you might be able to use them to detect a swipe gesture - e.g. detect the start and end of a 'drag' action and determine if it is long enough to represent a 'swipe').

    You should be able to create an event handler that detects the drag or swipe gesture, then in that event handler remove the item from the data source.

    You will probably need to use INotifyPropertyChanged on your datasource if you don't already have this implemented (or it might not update the UI when you remove the item).


    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.

    Thursday, September 5, 2013 12:38 AM
  • Hi TKorb,

    Why dragging does not work, try the code following, enable the "CanDragItems"

    private void DragItemsStarting(object sender, DragItemsStartingEventArgs e)
    {
       var  draggedItem = e.Items[0];
       gridview.Items.Remove(draggedItem);
    }

    It will looks fine like android does.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Thursday, September 5, 2013 11:11 AM
    Moderator

All replies

  • I'd investigate the following:

    IsSwipeEnabled property (I'm not sure if this is detecting a swipe on an item in the gridview or on the gridview itself)

    All the Drag* actions available (these may provide a built-in swipe gesture or you might be able to use them to detect a swipe gesture - e.g. detect the start and end of a 'drag' action and determine if it is long enough to represent a 'swipe').

    You should be able to create an event handler that detects the drag or swipe gesture, then in that event handler remove the item from the data source.

    You will probably need to use INotifyPropertyChanged on your datasource if you don't already have this implemented (or it might not update the UI when you remove the item).


    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.

    Thursday, September 5, 2013 12:38 AM
  • Hi TKorb,

    Why dragging does not work, try the code following, enable the "CanDragItems"

    private void DragItemsStarting(object sender, DragItemsStartingEventArgs e)
    {
       var  draggedItem = e.Items[0];
       gridview.Items.Remove(draggedItem);
    }

    It will looks fine like android does.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Thursday, September 5, 2013 11:11 AM
    Moderator