触摸Windows Phone 8.1 RT中的屏幕

时间:2015-08-18 02:20:25

标签: c# windows-phone-8.1

我正在构建一个应用程序来查找屏幕上的坏点,我遇到了一个我无法自己解决的大问题。我的代码用于在用户触摸的位置在屏幕上绘制一个矩形。 我的XAML代码:

<Grid x:Name="mainGrid" Background="Gray">        
        <Canvas x:Name="myCanvas" Background="Purple" PointerMoved="digitizerGrid_PointerMoved" PointerReleased="digitizerGrid_PointerReleased">
            <Grid x:Name="digitizerGrid" Visibility="Visible"/>
        </Canvas>
</Grid>

和我的c#代码来处理事件:

private void digitizerGrid_PointerMoved(object sender, PointerRoutedEventArgs e)
    {
        PointerPoint pt = e.GetCurrentPoint(myCanvas);
        Point currentContactPt = pt.Position;
        double x2 = currentContactPt.X;
        double y2 = currentContactPt.Y;
        Rectangle rect = new Rectangle()
        {
            Width = 50,
            Height = 50,
            StrokeThickness = 20.0,
            Fill = new SolidColorBrush(Colors.Green)
        };
        Canvas.SetLeft(rect, x2);
        Canvas.SetTop(rect, y2);
        myCanvas.Children.Add(rect);
    }

当我触摸并填满所有屏幕时: enter image description here

我使用黑色像素块获得了错误的结果图片: enter image description here

所以我无法检测死像素在哪里。我错了什么? 提前谢谢!

0 个答案:

没有答案