gpt4 book ai didi

c# - Silverlight new TouchPoint() 导致程序崩溃

转载 作者:太空宇宙 更新时间:2023-11-03 14:08:30 25 4
gpt4 key购买 nike

我想在 Silverlight 中模拟 TouchPoint。以下代码已引发未处理的异常:

currentTouchPoints[i] = new TouchPoint();
currentTouchPoints[i].SetValue(TouchPoint.PositionProperty,
new Point(x[i]+100+i*100,y[i]+500));

第一次调用 new TouchPoint() 会使程序崩溃。

最佳答案

我想您可以调用新的 TouchPoint(),但是它的 TouchDevice 无效并且它的所有属性都是只读的,所以它没有用。

我自己还没有找到解决方案。

我会创建一个自定义类并改用它。

例如,如果您已经在代码中使用普通的 TouchPoint 并且不想更改所有内容,请导入此自定义命名空间而不是 System.Windows.Input

namespace MyTouchPoint 
{

class TouchPoint
{
public Point Position = new Point (0,0);
public TouchDevice TouchDevice = new TouchDevice();

TouchPoint (int id_, Point position_)
{
TouchDevice.Id = id_;
Position = position_;
}
};

class TouchDevice
{
public int Id = 0;
};

} // end namespace

干杯,洛伦佐

关于c# - Silverlight new TouchPoint() 导致程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8589830/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com