How do I position a "child" window?

Topics: Prism v2 - WPF 3.5
Jun 24, 2009 at 9:58 PM

I need to "popup" a window that contains a list of valid actions whenever the user hovers over a textblock/hyperlink.  This window has a beak pointer on it that should point to the hovered over location and needs to be positioned to the right of the location if there's room on the screen otherwise it needs to be located to the left of the location and lastly it must be positioned vertically such that it does not run off of either the top or bottom of the screen.  The "beak" is moved appropriately as the window's location is changed.  I've already implemented a window region adapter ( which doesn't allow me to compute and specify the exact window positioning. 

Where do I implement the positioning logic?



Jun 25, 2009 at 6:37 PM

Hi Glenn,


To set the Window position of the contrib region adapter, you could modify the code in the Views_CollectionChanged method of the WindowRegionAdapter class. For example:

//more code above

Window window = new Window();

window.Activated += new EventHandler(window_Activated);

window.Deactivated += new EventHandler(window_Deactivated);

window.Style = _windowStyle;

window.Content = view;

window.Closed += new EventHandler(window_Closed);

window.Owner = owner;

window.Top = 0;

window.Left = 0; //new lines: Show the window in the TopLeft corner.


// more code below


Also the Prism-v2 Reference Implementation for WPF there is a RegionPopupBehavior which you might find useful. Specifically, the WindowWrapper class in the StockTraderRI.Infrastructure project could allow you to set the position by editing its constructor:

public WindowWrapper()


            this.window = new Window();

            this.window.Left = 700; // new line

            this.window.Top = 700; // new line



These are just some ideas, because the specific implementation may vary. Of course, in your application, this would require some calculation possibly, to decide where to place the Window, but this is just a sample approach.

You probably will have to modify the behavior to decide where to place the view based on the application’s current UI distribution.


Please let me know if this helps.


Damian Schenkelman