How can I determine the top/left position of a label in WPF?
-
06-09-2019 - |
Question
I have a WPF label contained in a FlowLayoutPanel and I want to determine the position of the label when clicked with the mouse. I am trying to position a pop-up control where near to the label and just need it's location.
Solution
The Popup
control has this ability built-in. You can use the Placement
, PlacementTarget
, HorizontalOffset
and VerticalOffset
properties to control it.
That said, if you really want to find a point relative to another control, use the UIElement.TranslatePoint
method.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow