How to get a wpf button screen rectangle

Hi, I am trying to get a wpf button screen rectangle so that I can select it.

I use this to achieve the same:

AutomationPeer theBtnPeer = createPeerForElement (btn); Rect rect = theBtnPeer.GetBoundingScreenRectangle ();

This works great and gives me the correct rectangle.

However .. if the button is not currently visible, I call BringIntoView () on this btn, which successfully displays this button, however, when I find GetBoundingSCreenRectangle () again. it gives me the same old value that was there before I called BringIntoView ().

How to get the new bounding box of this button?

thank

+3
source share
2 answers

ActualHeight ActualWidth.

, .

- , : , , , , , - .

, , , .

+1

, , ScrollViewer.UpdateLayout(), , .

, , , Visual.PointToScreen(). . , :

btn.PointToScreen(new Point(0, 0));

? , , , , - ? , , , , .

0

Source: https://habr.com/ru/post/1766655/


All Articles