locked
ListView drag and drog works only in mouse mode

    Question

  • Hi,

    I have a ListView with CanDragItems and IsSwipeEnabled both equal to true, but the drag-and-drop only works when I use the mouse. According to msdn documentation the IsSwipeEnabled is what controls this behaviour for touch, but it is not working for me. Is there anything else I need to do? If it works in my laptop with a mouse the code must be correct, how come it doesn't work when I run the same code in my tablet? Any clues are very welcomed.

    NFG.


    NFG

    Wednesday, July 9, 2014 12:24 AM

Answers

  • Hi NFG,

    I have following code that works fine with ListView drag and drop by touch, you could see what's difference between your code and mine.

            <ListView HorizontalAlignment="Left" Height="297" Margin="212,118,0,0"
                      VerticalAlignment="Top" Width="373" CanDragItems="True" 
                      CanReorderItems="True" AllowDrop="True" >
                <ListViewItem Background="Azure"></ListViewItem>
                <ListViewItem Background="Azure"></ListViewItem>
                <ListViewItem Background="Azure"></ListViewItem>
                <ListViewItem Background="Azure"></ListViewItem>
            </ListView>

    And in touch mode, you have to drag more distance to enter a drag and drop mode, otherwise you will stay at  Cross-slide.

    --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.

    • Marked as answer by NFG Wednesday, July 9, 2014 5:05 AM
    Wednesday, July 9, 2014 2:44 AM
    Moderator

All replies

  • Hi NFG,

    I have following code that works fine with ListView drag and drop by touch, you could see what's difference between your code and mine.

            <ListView HorizontalAlignment="Left" Height="297" Margin="212,118,0,0"
                      VerticalAlignment="Top" Width="373" CanDragItems="True" 
                      CanReorderItems="True" AllowDrop="True" >
                <ListViewItem Background="Azure"></ListViewItem>
                <ListViewItem Background="Azure"></ListViewItem>
                <ListViewItem Background="Azure"></ListViewItem>
                <ListViewItem Background="Azure"></ListViewItem>
            </ListView>

    And in touch mode, you have to drag more distance to enter a drag and drop mode, otherwise you will stay at  Cross-slide.

    --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.

    • Marked as answer by NFG Wednesday, July 9, 2014 5:05 AM
    Wednesday, July 9, 2014 2:44 AM
    Moderator
  • Thanks, James.

    The main difference between my ListView and your answer was that I am not using CanReorderItems because this was causing an issue with code I wanted to be executed when the drag starts. The CanReorderItems would not cause the event to be raised. Anyway with or without CanReorderItems it doesn't work. I finally found the culprit. I had added a Style that was essentially the default one used by ListViews minus a few effects I didn't want. As soon as I removed the Style attribute, drag-and-drop started to work also for touch mode. I have probably commented out something in the default style that was required by the drag-and-drop. As it was just a minor cosmetic issue I will simply stay with the unmodified default style.

    Thanks for your answer.


    NFG

    Wednesday, July 9, 2014 5:03 AM