在Silverlight中改变触点的位置属性

本文关键字:位置 属性 触点 改变 Silverlight | 更新日期: 2023-09-27 18:17:59

我正在开发一个Silverlight应用程序。在这里我想模拟触点。是否有任何方法可以创建具有更改位置的触点或在创建后更改位置?我试过这个(从http://mail.java2s.com/Open-Source/CSharp/Testing/gesturetoolkit/TouchToolKit/Framework/Utility/TouchPointHelper.cs.htm):

TouchPoint touch = new TouchPoint();
touch.SetValue("Position", new point(x,y));

这个错误不起作用:"错误197参数1:不能从'string'转换为'System.Windows.DependencyProperty'"基本上我在尝试用不同的位置生成触点。

在Silverlight中改变触点的位置属性

您必须向TouchPoint.SetValue提供依赖属性:

touch.SetValue(TouchPoint.PositionProperty, new point(x,y));
注意,典型的应用程序不应该这样做,TouchPoint类的Position属性是只读的,这是有充分理由的。典型的应用程序代码不应该生成触点。如果你必须这样做,你应该问问自己是否有更好的方法。