© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•16mo ago•
1 reply
Picarl

WPF Window -> SkiaGrid Coordinate Conversion Logic Problem

Howdy folk!

I'm working on a WPF project that for a graphical editor using Skia/SKSurface/SKCanvas.

In this application I am tracking the coordinates of where the mouse is, and draw a rectangle (as a cursor) on the grid overtop of the existing image.

The issue: I cannot get my coordinate systems to line up, and I believe it's a consequence of poor translation or offsets that I can't quite figure out.

Pictured: A debug image (ignore the terrible color scheme and the fact that I don't know why the elements aren't filling), where my cursor (not pictured) is actually placed on the gray square, but the yellow cursor square (left and up) of where it should be.

So, before showing any code - I want to ask: Is there a standard way of doing this? I've tried using the .TranslatePoint() calls and Control.PointToScreen/PointFromScreen() methods in order to translate between points of reference, but nothing seems to really work...

Any help is appreciated. Thanks!
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

WPF Window Navigation
C#CC# / help
13mo ago
❔ wpf custom window
C#CC# / help
3y ago
WPF custom resizable window
C#CC# / help
2y ago
❔ WPF Problem
C#CC# / help
3y ago