There is a UI object on the page, how can I determine the mouse coordinates relative to this object on the PointerEntered event? My task is to display the resize cursor in the correct position. I kind of get the coordinates of the object and the mouse, but when, as I think, I move the mouse to 0: 0 and my object is there, the coordinates are different

My method

  private void Border_PointerEntered(object sender, PointerRoutedEventArgs e) { var border = sender as Border; var ct = (CompositeTransform)border.RenderTransform; var ttv = border.TransformToVisual(Window.Current.Content); var bordercoords = ttv.TransformPoint(new Point(0, 0)); var borderHeight = border.ActualHeight+ct.ScaleY; var borderWidth = border.ActualWidth+ct.ScaleX; var mouseAbsoluteCoords = Window.Current.CoreWindow.PointerPosition; if (bordercoords.Y -3>=mouseAbsoluteCoords.Y || mouseAbsoluteCoords.Y <= bordercoords.Y+3 && mouseAbsoluteCoords.X > bordercoords.X + 10 && mouseAbsoluteCoords.X < borderWidth - 10) { Window.Current.CoreWindow.PointerCursor = bottomTopCursor; } } 

I try to cover the upper border with a check, I imagine it this way: when the cursor is in the blue zone, the necessary cursor is activated. Similarly for other areas

    1 answer 1

    Make an invisible element where it is marked in blue, and on it make the cursor change as needed when hovering. Then it is not necessary to calculate anything.

    • And if the red frame is a Grid`a cell, can I create more cells around it and the element is slightly shifted to the center? - SmiLe
    • If this is a table with cells that need to be resized, then there is a ready control. - Make Makeluv
    • No, this is a picture in the Grid with buttons in the top row and the size does not change the cells, but the entire Grid - SmiLe
    • one
      Did I understand you correctly? joxi.ru/V2V5g9kIXkJjmv - SmiLe
    • It seems to be yes, but it is better to remove the overlay. - Make Makeluv