views:

43

answers:

2

I'm writing an app in WPF and want to make a "helper" window. The window needs to be resizable, with no minimize option and doesn't show in the taskbar. If the app receives focus, it should appear as well, but whether or not it's in front or behind the main window should be retained. When the main window is closed, it should close along with the app.

An example is a detached pane in Visual Studio.

I've made the helper windows not appear in the taskbar, but can't get the rest of the behaviors I want. If they're their own windows, they don't get focus along with the rest of the app. If I specify a the main window as their owner, the main window can't be on top of the helper window.

Anyone know a good way to approach this?

+1  A: 

I think what you are looking for is something like a "modeless" dialog box. I don't do WPF, but the description here seems pretty straightforward.

http://msdn.microsoft.com/en-us/library/aa969773.aspx

Ants
I've already tried that (unwittingly) by setting the owner and calling .Show() on the window. The problem is that the dialog always appears on top of the owner window, even when the owner window is in focus.Also that does not prevent minimizing the window.
RandomEngy
+1  A: 

You could try something like this:

<Window x:Class="HelperWindowDemo.HelperWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="HelperWindow" Height="300" Width="300"
    WindowStyle="ToolWindow"
    ShowInTaskbar="False">
<Grid>
    <TextBlock>Helper window..</TextBlock>
</Grid>

and however you want to show it, something to this effect:

private void AddHelperWindow_Click(object sender, RoutedEventArgs e)
    {
        var window = new HelperWindow { Owner = this };
        window.Show();
    }

its resizable, has no minimize options, doesn't show in the taskbar, appears when the app gets focus, closes with the main window... the only thing it doesn't cover is allowing these tool windows to be behind the main window.

CountBobula
I had figured out the ToolWindow thing on my own, but thanks. Anyway, I'd still want the main window to be able to be in front of the helper windows.
RandomEngy