Exemple #1
0
        private async void TargetListView_Drop(object sender, DragEventArgs e)
        {
            if (e.DataView.Contains(StandardDataFormats.Text))
            {
                var def = e.GetDeferral();
                var s   = await e.DataView.GetTextAsync();

                string[]             items = s.Split('\n');
                View.MonsterSoloView msv   = new MonsterSoloView();
                msv.DataContext = monsterList.GetMonsterByID(Convert.ToInt32(items[0]));
                SelectedMonsterList.Add(monsterList.GetMonsterByID(Convert.ToInt32(items[0])));

                msv.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Center);
                msv.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Center);
                Grid grid = sender as Grid;
                foreach (var element in grid.Children)
                {
                    View.MonsterSoloView msvelement = element as View.MonsterSoloView;
                    SelectedMonsterList.monsterList.Remove(msvelement.DataContext as Monster);
                    grid.Children.Remove(element);
                }
                grid.Children.Add(msv);


                e.AcceptedOperation = DataPackageOperation.Copy;
                def.Complete();
                selectedMonsterGridView.DataContext = new ObservableCollection <Monster>(SelectedMonsterList.monsterList);
            }
        }
        private async void TargetListView_Drop(object sender, DragEventArgs e)
        {
            if (e.DataView.Contains(StandardDataFormats.Text))
            {
                var def = e.GetDeferral();
                var s = await e.DataView.GetTextAsync();
                string[] items = s.Split('\n');
                View.MonsterSoloView msv = new MonsterSoloView();
                msv.DataContext = monsterList.GetMonsterByID(Convert.ToInt32(items[0]));
                SelectedMonsterList.Add(monsterList.GetMonsterByID(Convert.ToInt32(items[0])));

                msv.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Center);
                msv.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Center);
                Grid grid = sender as Grid;
                foreach (var element in grid.Children)
                {
                    View.MonsterSoloView msvelement = element as View.MonsterSoloView;
                    SelectedMonsterList.monsterList.Remove(msvelement.DataContext as Monster);
                    grid.Children.Remove(element);
                    
                }
                grid.Children.Add(msv);

           
                e.AcceptedOperation = DataPackageOperation.Copy;
                def.Complete();
                selectedMonsterGridView.DataContext = new ObservableCollection<Monster>(SelectedMonsterList.monsterList);
            }
        }