예제 #1
0
        private async void ItemListView2_Drop(object sender, DragEventArgs e)
        {
            string itemIndexString = await e.Data.GetView().GetTextAsync("itemIndex");

            var item = storeData.Collection[int.Parse(itemIndexString)];

            Point pos = e.GetPosition(ItemListView2.ItemsPanelRoot);

            ListViewItem lvi        = (ListViewItem)ItemListView2.ContainerFromIndex(0);
            double       itemHeight = lvi.ActualHeight + lvi.Margin.Top + lvi.Margin.Bottom;

            int index = Math.Min(ItemListView2.Items.Count - 1, (int)(pos.Y / itemHeight));

            ListViewItem targetItem = (ListViewItem)ItemListView2.ContainerFromIndex(index);

            Point positionInItem = e.GetPosition(targetItem);

            if (positionInItem.Y > itemHeight / 2)
            {
                index++;
            }

            index = Math.Min(ItemListView2.Items.Count, index);

            storeData2.Collection.Insert(index, item);
        }
예제 #2
0
        void dropList_DragLeave(object sender, DragEventArgs e)
        {
            ListViewItem lvidropOld = (ListViewItem)ItemListView2.ContainerFromIndex(currDropIndex);

            lvidropOld.BorderThickness = noBorder;
            currDropIndex = -1;
        }
예제 #3
0
        private async void ItemListView2_Drop(object sender, DragEventArgs e)
        {
            string data = await e.Data.GetView().GetTextAsync("data");

            //Find the position where item will be dropped in the listview
            Point pos = e.GetPosition(ItemListView2.ItemsPanelRoot);

            //Get the size of one of the list items
            ListViewItem lvi        = (ListViewItem)ItemListView2.ContainerFromIndex(0);
            double       itemHeight = lvi.ActualHeight + lvi.Margin.Top + lvi.Margin.Bottom;

            //Determine the index of the item from the item position (assumed all items are the same size)
            int index = Math.Min(ItemListView2.Items.Count - 1, (int)(pos.Y / itemHeight));

            rootPage.NotifyUser("You dropped \'" + data + "\' from the first list onto item \'" + (index + 1) + "\' of the second list", NotifyType.StatusMessage);

            //Remove the border from the item
            ListViewItem lvidropOld = (ListViewItem)ItemListView2.ContainerFromIndex(currDropIndex);

            lvidropOld.BorderThickness = noBorder;
        }
예제 #4
0
        void dropList_DragOver(object sender, DragEventArgs e)
        {
            var          pos        = e.GetPosition(ItemListView2.ItemsPanelRoot);
            ListViewItem lvi        = (ListViewItem)ItemListView2.ContainerFromIndex(0);
            double       itemHeight = lvi.ActualHeight + lvi.Margin.Top + lvi.Margin.Bottom;

            int          index   = Math.Min(ItemListView2.Items.Count - 1, (int)(pos.Y / itemHeight));
            ListViewItem lvidrop = (ListViewItem)ItemListView2.ContainerFromIndex(index);

            if (index != currDropIndex)
            {
                if (currDropIndex >= 0)
                {
                    //remove the border
                    ListViewItem lvidropOld = (ListViewItem)ItemListView2.ContainerFromIndex(currDropIndex);
                    lvidropOld.BorderThickness = noBorder;
                }
                lvidrop.BorderBrush     = blueBorder;
                lvidrop.BorderThickness = thickBorder;
                currDropIndex           = index;
            }
        }