开发者

WPF:Enclose controls within a child window chrome which has a close button

I'm a C++ programmer and I've started a side project to teach me some WPF. I've started making a desktop app to browse images and probably retouch them, something like paint.net.

I want to enclose controls(e.g. see image below) within a child window ch开发者_JAVA技巧rome which has a close button. Something like MDI, but not quite.

WPF:Enclose controls within a child window chrome which has a close button

The simplest way for now, I thought, was to enclose it within another <window></window>, but it seems WPF doesn't like this. It gives a runtime exception.

Is there a simpler way of doing it. I couldn't find any links that explained anything similar.


To use Window you need to create a new Window class in a separate file which you can then instantiate and show from your main Window's code.

var childWindow = new MyChildWindow();
childWindow.Show();

To get the simplified window chrome set WindowStyle = WindowStyle.ToolWindow in MyChildWindow.

If you're trying to create a contained simulated window inside your main window that needs to use a normal non-Window control. Silverlight includes a ChildWindow class but it's not built into WPF. To create something similar you can use a HeaderedContentControl which you'll have to style to look like a tool window by modifying the ControlTemplate. You'll also need to create behaviors like drag, resize and close on the control which is usually best handled by making it a custom control.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜