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

Mobile
»
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
»
WPF, UWP: Create transparent app window
»
WPF: Determine the relative position of an element

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de