locked
WinRT ListView Reordering - drag and drop into all direcetions

    Question

  • Hi everyone.

    Im developing universal app., wp8.1 and w8 (tablet). 

    1. Have a ListView. 5 items in one row ( there can be more rows ).
    2. CanDragItems, AllowDrop, CanReorderItems properties are all true.

    Issue: i cant drag items with vertical moves/gestures but only horizontally ( left right). This is probably because user can scroll vertically..

    My idea is to disable reordering by default and only enable it after item long press (hold) and then want to drag/reorder into any direction and not only left,and right.

    Note: I try to implement this for tablet.

    <ListView ItemsSource="{Binding Items}" CanReorderItems="True" SelectionMode="None" AllowDrop="True" CanDragItems="True">
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <ItemsWrapGrid HorizontalAlignment="Stretch" Orientation="Horizontal" MaximumRowsOrColumns="3"/>
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
    
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Grid Width="200" Height="200" Background="Green"/>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

    Any tips or suggestions are very welcome.

    Many thanks

    • Edited by Jano85 Wednesday, September 24, 2014 9:31 PM
    Wednesday, September 24, 2014 9:29 PM

Answers

  • Hi Jano85,

    That could be a good idea, but you may need to confirm whether the ScrollViewer inside ListView ate your gesture. You can disable the ListView scroll behavior and test if you can successfully drag and drop. As you can see from: ListView styles and templates, to set ScrollViewer.HorizontalScrollMode or ScrollViewer.VerticalScrollMode as disable is necessary.

        <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Disabled" />
        <Setter Property="ScrollViewer.VerticalScrollMode" Value="Disabled" />

    If you can confirm the ScrollViewer ate your gesture, you could implement your idea.

    --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 25, 2014 9:58 AM
    Moderator