cs代码:
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace SilverlightApplication50 { public partial class EventMouse : UserControl { public EventMouse() { InitializeComponent(); } private void Canvas_MouseMove(object sender, MouseEventArgs e) { Point p =e.GetPosition(null); this.mybutton.SetValue(Canvas.LeftProperty, p.X); this.mybutton.SetValue(Canvas.TopProperty, p.Y); this.TextBlock1.Text = string.Format("X坐标是{0},Y坐标是{1}", p.X, p.Y); } } }