Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect that a control is being moved?

Suppose I have a window with a custom UserControl, and the UserControl has a textbox inside. When I drag the window around, how can the TextBox detect that it is being moved ?

I tried to search around its RenderTransform property, there is that Change event that gets fired when "the Freezable object or one of its objects change". Nothing conclusive..

Edit :

In my case, I don't see the window, all I see is the UserControl and I can't go any higher.

like image 946
Mohamed Avatar asked May 10 '11 10:05

Mohamed


2 Answers

You will need to subscribe to the Window events, as your textbox is not actually moving (its most likely in the same position relevant to the window) so you can subscribe to the Window.LocationChanged event to be notified when the window is moved.

But Also If your control does not have an absolute position then you will need to parse Window.SizeChanged which will tell you when the user has resized the window, but it’s a discrete final event as opposed to an in-progress event.

like image 176
Michal Ciechan Avatar answered Oct 23 '22 17:10

Michal Ciechan


Try subscribing to the LayoutUpdated event of the UserControl.

like image 26
Eternal21 Avatar answered Oct 23 '22 18:10

Eternal21