日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
如何正確實現(xiàn)Silverlight拖拽功能

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

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

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

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拖拽功能的實現(xiàn)方法就為大家介紹到這里啦。


網(wǎng)站欄目:如何正確實現(xiàn)Silverlight拖拽功能
文章源于:http://www.dlmjj.cn/article/coedgpd.html