Free Code Snippets in C#, Net Framework, Office 365, ASP.Net,WPF, Visual Studio, SQL Server, Antivirus free

WPF: Determine the relative position of an element


Under WPF, you can use TranslatePoint (..) The position of a subordinate element to the upper left corner of a parent element.


C # Code example

UIElement child_Element = e.Source as UIElement ;

Point position = this.TranslatePoint(new Point(0, 0), child_Element );


double X = position.X;


This is the MainWindows in this case

Child_Element is calculated from the mouse pointer argument in the example



In the example shown, an X value of the position with minus 245 points is obtained

WPF: Set Startup Window
Add WPF Local SQL Database to Application and Connect Data
WPF / UWP: Canvas with relative positions and sizes
C #, WPF, UWP: ScreenShot to save an app or window area as a file
C #: Windows ScreenShot save as file
WPF Color Picker on Color Cube
WPF: Draw ColorWheel in C# by drawing Lines
WPF: Snap In to Next Lines of Elements
WPF Code: Usercontrol with customizable size at runtime
WPF: Save the background of a Windows app as a ScreenShot


Contact for Jobs, Project Requests: