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

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
SilverLight拖動具體實現(xiàn)方式介紹

SilverLight的使用可以幫助開發(fā)人員輕松的解決一些以前愛只能依靠美工才能解決的相關(guān)開發(fā)問題?,F(xiàn)在我們將會學到其中的一個使用技巧,就是SilverLight拖動的實現(xiàn)方式。#t#

創(chuàng)新互聯(lián)公司是一家專業(yè)提供汕城企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站制作、網(wǎng)站建設(shè)、HTML5、小程序制作等業(yè)務(wù)。10年已為汕城眾多企業(yè)、政府機構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)的建站公司優(yōu)惠進行中。

SilverLight拖動前臺代碼:

  1. < UserControl 
  2. xmlns="http://schemas.microsoft.
    com/winfx/2006/xaml/presentation"
     
  3. xmlns:x="http://schemas.
    microsoft.com/winfx/2006/xaml"
     
  4. x:Class="SilverlightApplic
    ation6.Page"
     
  5. Width="640" Height="480"> 
  6. < Canvas x:Name="LayoutRoot" 
    Background="White"> 
  7. < Image Margin="263,185,249,167" 
    Source="1.png" Stretch="Fill" 
    MouseLeftButtonDown="Image_
    MouseLeftButtonDown"
       
  8. MouseMove="Image_MouseMove" 
  9. MouseLeftButtonUp="Image_
    MouseLeftButtonUp"
    /> 
  10. < /Canvas> 
  11. < /UserControl> 

SilverLight拖動后臺代碼:

 
 
 
  1. using System;  
  2. using System.Windows;  
  3. using System.Windows.Controls;  
  4. using System.Windows.Documents;  
  5. using System.Windows.Ink;  
  6. using System.Windows.Input;  
  7. using System.Windows.Media;  
  8. using System.Windows.Media.Animation;  
  9. using System.Windows.Shapes;  
  10. namespace SilverlightApplication6  
  11. {  
  12. public partial class Page : UserControl  
  13. {  
  14. bool trackingMouseMove = false;  
  15. Point mousePosition;  
  16. public Page()  
  17. {  
  18. // 需要初始化變量  
  19. InitializeComponent();  
  20. }  
  21. private void Image_MouseLeftButtonDown
    (object sender, MouseButtonEventArgs e)  
  22. {  
  23. FrameworkElement element = 
    sender as FrameworkElement;  
  24. mousePosition = e.GetPosition(null);  
  25. trackingMouseMove = true;  
  26. if (null != element)  
  27. {  
  28. element.CaptureMouse();  
  29. element.Cursor = Cursors.Hand;  
  30. }  
  31. }  
  32. private void Image_MouseMove(object 
    sender, MouseEventArgs e)  
  33. {  
  34. FrameworkElement element = sender 
    as FrameworkElement;  
  35. if (trackingMouseMove)  
  36. {  
  37. double deltaV = e.GetPosition(null).
    Y - mousePosition.Y;  
  38. double deltaH = e.GetPosition(null).
    X - mousePosition.X;  
  39. double newTop = deltaV + (double)element.
    GetValue(Canvas.TopProperty);  
  40. double newLeft = deltaH + (double)
    element.GetValue(Canvas.LeftProperty);  
  41. element.SetValue(Canvas.TopProperty, newTop);  
  42. element.SetValue(Canvas.LeftProperty, newLeft);  
  43. mousePosition = e.GetPosition(null);  
  44. }  
  45. }  
  46. private void Image_MouseLeftButtonUp
    (object sender, MouseButtonEventArgs e)  
  47. {  
  48. FrameworkElement element = sender 
    as FrameworkElement;  
  49. trackingMouseMove = false;  
  50. element.ReleaseMouseCapture();  
  51. mousePositionmousePosition.X = 
    mousePosition.Y = 0;  
  52. element.Cursor = null;  
  53. }  
  54. }  

以上就是對SilverLight拖動相關(guān)實現(xiàn)方法做得具體介紹。


本文題目:SilverLight拖動具體實現(xiàn)方式介紹
網(wǎng)站路徑:http://www.dlmjj.cn/article/ccscgho.html