Children's docked window

Greetings

I would like the child window to dock next to my parent window. If I move the parent window, the child window must also be moved. The image below should explain what I would like to achieve:
http://img689.imageshack.us/img689/1305/childdockedwindow.jpg
Can someone help me please. I am writing in WPF. Does anyone know how to do this?

+4
source share
1 answer

Handle Window.LocationChanged events and Window.LocationChanged events in the main window. When one of these events occurs, calculate the new location for the child window.

Here is an idea:

 var mainWindow = ...; var childWindow = ...; var handler = new EventHandler(() => { childWindow.Top = mainWindow.Top; childWindow.Left = mainWindow.Left + mainWindow.Width; }); mainWindow.LocationChanged += handler; mainWindow.SizeChanged += handler; 

You may also need code that removes the handler from both events when the child window no longer needs to dock or no longer works.

+1
source

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


All Articles