av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

如何正確實(shí)現(xiàn)Silverlight拖拽功能

Silverlight拖拽功能的實(shí)現(xiàn)再實(shí)際開(kāi)發(fā)編程中是一個(gè)非常重要的基礎(chǔ)功能。對(duì)于一個(gè)開(kāi)發(fā)人員來(lái)說(shuō),如果想要很好的使用Silverlight來(lái)實(shí)現(xiàn)相關(guān)功能需求,就需要牢固掌握這些基礎(chǔ)功能的應(yīng)用。#t#

網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)公司!專(zhuān)注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、重慶小程序開(kāi)發(fā)公司、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶(hù)創(chuàng)新互聯(lián)還提供了舟曲免費(fèi)建站歡迎大家使用!

下面的示例演示如何在基于 Silverlight 的應(yīng)用程序中拖放對(duì)象。出于安全考慮,不能在應(yīng)用程序之間拖放對(duì)象。因此,說(shuō)成在 Silverlight 插件區(qū)域內(nèi)"滑動(dòng)"對(duì)象更為準(zhǔn)確。但是,術(shù)語(yǔ)"拖放"更為人知,因此在此處使用。

Silverlight拖拽功能Xaml腳本:

  1. < UserControl x:Class=
    "DragAndDropSimple.Page" 
  2. xmlns="http://schemas.microsoft.
    com/winfx/2006/xaml/presentation"
       
  3. xmlns:x="http://schemas.
    microsoft.com/winfx/2006/xaml"
       
  4. Width="400" Height="300"> 
  5. < Canvas x:Name="rootCanvas" 
  6. Width="640" 
  7. Height="480" 
  8. Background="Gray" 
  9. > 
  10. < !-- You can drag this 
    rectangle around the canvas. --> 
  11. < Rectangle 
  12. MouseLeftButtonDown=
    "Handle_MouseDown" 
  13. MouseMove="Handle_MouseMove" 
  14. MouseLeftButtonUp="Handle_MouseUp" 
  15. Canvas.Left="30" Canvas.
    Top
    ="30" Fill="Red" 
  16. Width="50" Height="50" /> 
  17. < /Canvas> 
  18. < /UserControl> 

后置代碼:

 
 
 
  1. // Global variables used to 
    keep track of the   
  2. // mouse position and whether 
    the object is captured  
  3. // by the mouse.  
  4. bool isMouseCaptured;  
  5. double mouseVerticalPosition;  
  6. double mouseHorizontalPosition;  
  7. public void Handle_MouseDown 
    (object sender, MouseEventArgs args)   
  8. {  
  9. Rectangle item = sender as Rectangle;  
  10. mouseVerticalPosition = args.
    GetPosition(null).Y;  
  11. mouseHorizontalPosition = 
    args.GetPosition(null).X;  
  12. isMouseCaptured = true;  
  13. item.CaptureMouse();  
  14. }  
  15. public void Handle_MouseMove
    (object sender, MouseEventArgs args)   
  16. {  
  17. Rectangle item = sender as Rectangle;  
  18. if (isMouseCaptured)   
  19. {  
  20. // Calculate the current 
    position of the object.  
  21. double deltaV = args.GetPosition(null).
    Y - mouseVerticalPosition;  
  22. double deltaH = args.GetPosition(null).
    X - mouseHorizontalPosition;  
  23. double newTop = deltaV + (double)
    item.GetValue(Canvas.TopProperty);  
  24. double newLeft = deltaH + (double)
    item.GetValue(Canvas.LeftProperty);  
  25. // Set new position of object.  
  26. item.SetValue(Canvas.TopProperty, newTop);  
  27. item.SetValue(Canvas.LeftProperty, newLeft);  
  28. // Update position global variables.  
  29. mouseVerticalPosition = args.
    GetPosition(null).Y;  
  30. mouseHorizontalPosition = args.
    GetPosition(null).X;  
  31. }  
  32. }  
  33. public void Handle_MouseUp(object 
    sender, MouseEventArgs args)   
  34. {  
  35. Rectangle item = sender as Rectangle;  
  36. isMouseCaptured = false;  
  37. item.ReleaseMouseCapture();  
  38. mouseVerticalPosition = -1;  
  39. mouseHorizontalPosition = -1;  

Silverlight拖拽功能的實(shí)現(xiàn)方法就為大家介紹到這里啦。


網(wǎng)站欄目:如何正確實(shí)現(xiàn)Silverlight拖拽功能
瀏覽路徑:http://uogjgqi.cn/article/coedgpd.html
掃二維碼與項(xiàng)目經(jīng)理溝通

我們?cè)谖⑿派?4小時(shí)期待你的聲音

解答本文疑問(wèn)/技術(shù)咨詢(xún)/運(yùn)營(yíng)咨詢(xún)/技術(shù)建議/互聯(lián)網(wǎng)交流