如何在UWP中获取PointToScreen

时间:2016-07-25 13:16:55

标签: wpf xaml uwp

在WPF中,这样的东西会告诉我左上角的位置:

set colorcode to (choose color)
set password1 to text returned of (display dialog "Write the colorcode " & colorcode & " down below" default answer "" buttons {"continue", "cancel"} default button 1 cancel button 2)
if (colorcode as text) is password1 then
    display dialog "correct" buttons {"1", "2"}
else
    display dialog "false" buttons {"1", "2"}
end if

如何在UWP中获得相同的内容?我找不到任何方法来获得它。

谢谢:)

2 个答案:

答案 0 :(得分:7)

您可以按以下步骤获取UIElement的屏幕坐标:

  1. 通过以下代码获取UIElement相对于当前应用程序窗口的坐标:

    GeneralTransform transform = myBorder.TransformToVisual(Window.Current.Content);
    Point coordinatePointToWindow = transform.TransformPoint(new Point(0, 0));
    
  2. 获取当前应用程序窗口的Rect信息:

    Rect rect = Window.Current.CoreWindow.Bounds;
    
  3. 计算您的UIElement的坐标:

    var left = coordinatePointToWindow.X + rect.Left;
    var top = coordinatePointToWindow.Y + rect.Top;
    

答案 1 :(得分:3)

您可以使用SELECT a.map, a.time, a.jumps, a.id, a.auth, b.rank FROM ( SELECT pt.map, pt.time, pt.jumps, pt.id, pt.auth FROM playertimes pt WHERE auth = '[U:1:204506329]' AND style = 0 ORDER BY MAP ) a LEFT JOIN ( SELECT COUNT(*) rank, pt.auth FROM playertimes pt LEFT JOIN users u ON u.auth = pt.auth WHERE pt.time <= ( SELECT time FROM playertimes WHERE MAP = 'bhop_horsepoop_8' AND style = 0 AND auth = '[U:1:204506329]' LIMIT 1 ) AND pt.MAP = 'bhop_horsepoop_8' AND pt.style = 0 ORDER BY time ASC LIMIT 1 ) b ON a.auth = b.auth; 方法。使用以下代码

rank