Constraining child windows - wpf

I'm writing a WPF application to control an industrial process. The main window class spawns child windows, each to control a separate piece of equipment. These child windows can be dragged but not resized.
The child windows are owned by the parent so they stay on top, but the problem this creates is that they can be dragged on top of the main window menu, which is considered aesthetically unacceptable by my client.
It would be OK if the child window goes under the menu or if it goes right up to the menu and stops but it's not OK to obscure the main menu. How can I achieve this? Can it be done within WPF without going into Win32 and unmanaged code?
Thanks in advance.

You could try to set Topmost=True on the parent window, and make it only contain the main menu. So, you'd basically have one window for the main menu and a couple of others for everything else. Or, if you can't do that, you can create a main menu window with Topmost=True as a child window of your parent, and move both of them together whenever one of them changes position.

Related

Paint child window that overflows outside top-level window

Is it possible to paint my child window that overflows outside its parent top-level window? I've seen combo-boxes can do this when their drop down is taller than the top-level window.
For example:
My window is a custom class with the style flags CS_HREDRAW | CS_VREDRAW. From what I understand I could use WS_EX_LAYERED? Or I could make the window taller and transparent to give the appearance of the window overflowing but those transparent areas either side of the red overflow are going to be Windows Message 'blackholes' that would really annoy the user if they click there expecting to be interacting with a different top-level window.
Is it possible to paint my child window that overflows outside its parent top-level window?
No. By definition, a child window
[...] is confined to the client area of its parent window.
But that's not what you need anyway. If you want to mimic the behavior of a combo box control, you need to create an owned pop-up window instead (see Owned Windows).

Snoop doesn't see my application's child windows

When I run Snoop 2.8, it sees my program's main window and lists it in its ComboBox. However, my program creates a child window that is displayed by calling ChildWindow.Show(). No matter what I do, I can't snoop that child window. If I refresh the list of windows, it doesn't show up. If I drag the little cross hairs icon next to the binoculars over the child window, the main window comes up.
How do I Snoop my applicaton's child window?
When I use Snoop, I always first start snoop and then use the "shift+control" shortcut to focus on what I want. This seems to work even if I do it to a child window. So try this:
Start application, open child window
Run Snoop
Snoop any window in the application
Focus on your child window (click on the title bar of the window)
Move the mouse over what you want to inspect, and hold down the Shift and Control keys simultaneously
A red outline appears in your application, and you should see Snoop show/select the element in question in the tree. If you look up the visual tree on the left you will now see the child window is the parent of the tree.
This solution was last tested in Snoop 2.8.
Have you ever look for WPF Inspector? I always use it instead of snoop and and never had any problem with child windows...
http://wpfinspector.codeplex.com/

Silverlight 4 Non-Moveable or Non-Moveable Offscreen Child Window

I've read articles that Child Windows in SL3 cannot be set to non-moveable, without creating your own custom window. Was this fixed in SL4? This is a problem, because the user is able to drag windows off the silverlight stage, which seems like an awkard UI design. On my first try I moved it offscreen and was not able to move it back or close it. I do not understand the logic behind leaving out the option to make the window non-moveable.
Is there any other way to prevent the user from dragging a child window off the screen? Or is creating my own custom window the only way.
I created my own custom Style which gets rid of the close button in the header and stops the moving.
In your control set: <controls:ChildWindow ... Style="{StaticResource themeChildWindowStyle}"
You can create the style with Blend pretty easy.
Here's a discussion on this topic which has another solution from "friendy1108" ~"My solution right now is to hide the title bar and make a button to close the child window.
From the link you sent, I can do this: title.Visibility = Visibility.Collapsed;" That would do it, but I prefer the style override.

always on top child window in multiple child windows in silverlight

I have several child windows and i want one of the these child windows always on top of all other opened child windows. i want when i do close or open other child windows, this child window always on top of all current child windows.
child window not have a z-index property?
please help me, thanks
I have not a lot of work experience with child windows, but have some idea...). If child window is a part of to inherited tree of FrameworkElement then you can try call "Focus" method for displaying it on the top.

Lock a window position to another window?

I am using a transparent borderless WPF window to get around some drawing limitations of my ESRI ArcEngine which is displayed in a WindowsFormHost in a WPF window. When I move the my app window, I want to move the transparent window at the same time. Is there a way to snap these two windows together so they move together?
There is no facility for "snapping" windows together per se but you can accomplish the same thing very effectively by event handling:
handle the size change event of the parent window
handle the location change event of the parent window
For any of the above-listed events:
update the size and location of the child window to that of the parent window
It sounds hacky, and it is, but works pretty seamlessly. Windows size and move events fire often enough that your windows will look glued together.

Resources