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
»
C # Application: Webrobot to read all Ebay Kleinanzeigen
»
WPF: Navigate to a page
»
WPF: create a selectable list
»
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

.

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