當前位置: 首頁>>代碼示例>>C#>>正文


C# DragEventArgs.GetDeferral方法代碼示例

本文整理匯總了C#中Windows.UI.Xaml.DragEventArgs.GetDeferral方法的典型用法代碼示例。如果您正苦於以下問題:C# DragEventArgs.GetDeferral方法的具體用法?C# DragEventArgs.GetDeferral怎麽用?C# DragEventArgs.GetDeferral使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.UI.Xaml.DragEventArgs的用法示例。


在下文中一共展示了DragEventArgs.GetDeferral方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TargetListView_Drop

        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);
            }
        }
開發者ID:NestedWorld,項目名稱:Windows10,代碼行數:29,代碼來源:UserMonsterListView.xaml.cs

示例2: Grid_OnDrop

        private async void Grid_OnDrop(object sender, DragEventArgs e)
        {
            Locator.ViewModels.NewThreadVm.IsLoading = true;
            var d = e.GetDeferral();

            var files = await e.DataView.GetStorageItemsAsync();
            foreach (var file in files)
            {
                await Locator.ViewModels.NewThreadVm.ImgurAddImageCommand.AddImgurImage(file as StorageFile, ReplyText);
            }
            d.Complete();
            Locator.ViewModels.NewThreadVm.IsLoading = false;
        }
開發者ID:Ephemerial,項目名稱:Awful-Forums-Reader,代碼行數:13,代碼來源:NewThreadPage.xaml.cs

示例3: TargetListView_Drop

        /// <summary>
        /// We need to return the effective operation from Drop
        /// This is not important for our source ListView, but it might be if the user
        /// drags text from another source
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void TargetListView_Drop(object sender, DragEventArgs e)
        {
            if (e.DataView.Contains(StandardDataFormats.Text))
            {
                var def = e.GetDeferral();
                var id = await e.DataView.GetTextAsync();
                var itemIdsToMove = id.Split(',');

                var destinationListView = sender as ListView;
                var listViewItemsSource = destinationListView?.ItemsSource as ObservableCollection<Palestrante>;

                if (listViewItemsSource != null)
                {
                    foreach (var itemId in itemIdsToMove)
                    {
                        var itemToMove = ListSource.First(i => i.nome.ToString() == itemId);
                        listViewItemsSource.Add(itemToMove);
                        //ListSource.Remove(itemToMove);
                    }
                }
                e.AcceptedOperation = DataPackageOperation.Copy;
                def.Complete();
            }
        }
開發者ID:rogeriohc,項目名稱:NavPaneApp1,代碼行數:31,代碼來源:Page2.xaml.cs

示例4: dropimg

 public async void dropimg(object sender, DragEventArgs e)
 {
     DragOperationDeferral defer = e.GetDeferral();
     try
     {
         DataPackageView data_view = e.DataView;
         string str = await clipboard(data_view);
         clipboard_substitution(str);
     }
     finally
     {
         defer.Complete();
     }
 }
開發者ID:lindexi,項目名稱:Markdown,代碼行數:14,代碼來源:winmain.cs

示例5: Dropimg

 public async void Dropimg(object sender, DragEventArgs e)
 {
     if (Writetext)
     {
         return;
     }
     DragOperationDeferral defer = e.GetDeferral();
     try
     {
         DataPackageView dataView = e.DataView;
         string str = await _m.clipboard(dataView);
         Tianjia(str);
     }
     finally
     {
         defer.Complete();
     }
 }
開發者ID:lindexi,項目名稱:Markdown,代碼行數:18,代碼來源:viewModel.cs

示例6: TargetTextBlock_Drop

 /// <summary>
 /// Drop on the Trash
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void TargetTextBlock_Drop(object sender, DragEventArgs e)
 {
     if (e.DataView.Contains(StandardDataFormats.Text))
     {
         // We need to take the deferral as the source will read _deletedItem which
         // we cannot set synchronously
         var def = e.GetDeferral();
         _deletedItem = await e.DataView.GetTextAsync();
         e.AcceptedOperation = DataPackageOperation.Move;
         def.Complete();
     }
 }
開發者ID:C-C-D-I,項目名稱:Windows-universal-samples,代碼行數:17,代碼來源:Scenario1_ListView.xaml.cs

示例7: TargetListView_Drop

 /// <summary>
 /// We need to return the effective operation from Drop
 /// This is not important for our source ListView, but it might be if the user
 /// drags text from another source
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void TargetListView_Drop(object sender, DragEventArgs e)
 {
     // This test is in theory not needed as we returned DataPackageOperation.None if
     // the DataPackage did not contained text. However, it is always better if each
     // method is robust by itself
     if (e.DataView.Contains(StandardDataFormats.Text))
     {
         // We need to take a Deferral as we won't be able to confirm the end
         // of the operation synchronously
         var def = e.GetDeferral();
         var s = await e.DataView.GetTextAsync();
         var items = s.Split('\n');
         foreach (var item in items)
         {
             _selection.Add(item);
         }
         e.AcceptedOperation = DataPackageOperation.Copy;
         def.Complete();
     }
 }
開發者ID:C-C-D-I,項目名稱:Windows-universal-samples,代碼行數:27,代碼來源:Scenario1_ListView.xaml.cs

示例8: HandleDrop

        static async void HandleDrop(DragEventArgs e, Action<StorageFile> handleDroppedFile)
        {
            if (!e.DataView.Contains(StandardDataFormats.StorageItems))
                return;

            var deferral = e.GetDeferral();

            try
            {
                var storageItems = await e.DataView.GetStorageItemsAsync();

                var file = GetSingleImageFile(storageItems);

                if (file != null)
                {
                    handleDroppedFile(file);

                    e.Handled = true;
                }
            }
            finally
            {
                deferral.Complete();
            }
        }
開發者ID:shawnhar,項目名稱:stuart,代碼行數:25,代碼來源:MainPage.xaml.cs

示例9: Image_Drop

 private async void Image_Drop(object sender, DragEventArgs e)
 {
     var def = e.GetDeferral();
     var data = await e.DataView.GetTextAsync();
 }
開發者ID:akshay2000,項目名稱:MonocleGiraffe,代碼行數:5,代碼來源:EditItemPage.xaml.cs


注:本文中的Windows.UI.Xaml.DragEventArgs.GetDeferral方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。