我有多个窗口(.xaml 文件)。我想将一个窗口停靠在另一个窗口中。
说,我有一个 ParentWindow.xaml。在 ParentWindow 中单击一个按钮,我打开 ChildWindow.xaml。打开 ChildWindow.xaml 后,我必须将其停靠在 ParentWindow.xaml 中。
如何实施?
看看这个库: http: //www.codeproject.com/KB/WPF/WPFdockinglib.aspx
我认为你正在寻找的是一个 MDI 接口。这在 WPF 中是不可能的:窗口的子级不能是窗口,它们只能是控件。
相反,您可以将 your 更改ChildWindow
为 aUserControl
并将其显示在 a 中TabControl
。大多数现代 UI 现在使用选项卡而不是 MDI...
你想像小部件一样停靠在 MainWindow 中还是想将其内容停靠在 MainWindow UIElement 中?
让我们在 mainwindow.xaml.vb 中试试这个:
Dim NewMyWinChild As Window2 = New Window2()
Dim TheMyContent As Object = NewMyWinChild.Content
GridNameOfMyUIElemnt.Children.Add(TheMyContent)
这会将 Window2 的内容添加到运行时的 GridNameOfMyUIElemnt-mainwindow.xaml。
我想如果你想要小部件,那么你可以设置“Z-panel index”属性。
MDI,是的,它可以,只是谷歌搜索,但它旧了。
(在 .Net 3.0 的 VB 2005 express 中我可以正常工作)