在另一个 wpf 窗口中有一个 wpf 窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1287820/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Have a wpf window inside another wpf window
提问by Danish Munir
Is there a way to host a WPF window inside another WPF window. I have a couple of somewhat complex forms in place. But now to simplify things I am trying to merge a few of them as tabpages inside one 'Dashboard' form.
有没有办法在另一个 WPF 窗口内托管 WPF 窗口。我有几个有点复杂的表格。但现在为了简化事情,我试图将其中一些合并为一个“仪表板”表单中的标签页。
Please note that I am not trying to host a Windows Form, but another WPF window
请注意,我不是要托管 Windows 窗体,而是要托管另一个 WPF 窗口
采纳答案by Thomas Levesque
If you want tabpages, why not use a TabControl with UserControls inside ? If you need to transform one of these tabs to a floating window, just put the UserControl in a new Window...
如果你想要标签页,为什么不使用带有 UserControls 的 TabControl 呢?如果您需要将这些选项卡之一转换为浮动窗口,只需将 UserControl 放在一个新窗口中...
回答by Sebastian Gray
Can I answer this question with another question; why would you not create them as controls rather than other WPF windows, that you want to host in the main WPF window?
我可以用另一个问题来回答这个问题吗?为什么不将它们创建为控件而不是其他 WPF 窗口,您希望在主 WPF 窗口中托管?
回答by George Birbilis
a bit late on this, but I guess with WindowsForms interop you can put in WPF a WinForms control host and in that host put a WinForms control that hosts the handle of a WPF window
有点晚了,但我想使用 WindowsForms 互操作,您可以在 WPF 中放置一个 WinForms 控件主机,并在该主机中放置一个承载 WPF 窗口句柄的 WinForms 控件
回答by Kent Boogaart
I think what you're asking for is MDI, Multiple Document Interface. Something like thismight help.
我认为您要的是 MDI,即多文档界面。像这样的事情可能会有所帮助。
Do note, however, that the MDI paradigm is largely shunned these days. There are usually better ways to achieve the same functionality.
但是请注意,如今 MDI 范式在很大程度上被回避了。通常有更好的方法来实现相同的功能。
回答by BoboSurabaya
I think you want to hosting contents of WPF Window1.xaml (page1.xaml) inside within another WPF Window.
我认为您想在另一个 WPF 窗口中托管 WPF Window1.xaml (page1.xaml) 的内容。
Well...you can use Navigation. Instead running window1.xaml contents inside tab then you can work with your data inside Navigation. Navigation can run within WPF Window Application. You just design your form / UI in page1.xaml.
嗯...你可以使用导航。而是在选项卡内运行 window1.xaml 内容,然后您可以在导航中处理您的数据。导航可以在 WPF 窗口应用程序中运行。您只需在 page1.xaml 中设计表单/UI。
one another..MDI old and rusty. We want clear of top window nowadays.
另一个..MDI 又旧又生锈。我们现在想要清除顶部窗口。