c# - 如何将子窗体显示为 wpf 到 MDI 容器中是正常的 mdi 窗体

标签 c# wpf

如何在正常创建的 MDI 窗口窗体中显示 WPF 窗体。

我们将表单创建为 MDI。 增加菜单栏点击菜单会在主容器MDi窗体中显示wpf窗体。

enter image description here

 private void newStudentToolStripMenuItem_Click(object sender, EventArgs e)
    {

      StudentRegister student=  new StudentRegister();
     student.ShowDialog(); 
    }

问题是点击任务栏子窗体到外面去。

最佳答案

据我了解,您想在 MDI 页面中打开子页面。首先在 WPF 中没有 MDI 窗口。

如果您使用“student.ShowDialog();”,那么页面或窗口将作为弹出窗口打开。

可能的解决方案:--

您可以在主窗口上使用 ContentControl 并创建用户控件而不是窗口。然后您可以将用户控件添加到 ContentControl。

<Border ClipToBounds="True" Grid.Row="1" Background="WhiteSmoke">
  <ContentControl x:Name="DetailsControl" Margin="10" HorizontalAlignment="Left"    VerticalAlignment="Top" />
</Border>

var student= new StudentRegister ();
DetailsControl.Content = student;

下面的链接可能有帮助。

http://wpfmdi.codeplex.com/

http://www.codeplex.com/wikipage?ProjectName=AvalonDock

http://www.codeproject.com/Articles/22927/Multiple-Window-Interface-for-WPF

关于c# - 如何将子窗体显示为 wpf 到 MDI 容器中是正常的 mdi 窗体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23646973/

相关文章:

c# - 如何在本地/内部托管 Azure 辅助角色?

c# - 使用 XAML 绑定(bind)设置具有自定义标签的 LiveCharts 系列的颜色

c# - 在 C# 和 WCF 中具有存储库模式的 Web 服务?

c# - 在程序运行时编译/执行 XAML

c# - 由于域文件夹重定向,在 Environment.SpecialFolder.Favorites 上调用 Directory.GetDirectories 时出现 DirectoryNotFoundException

c# - 将整数拆分并存储为两个字节

javascript - 如何获取用户控件下拉列表的ClientID

wpf - 更新静态属性的绑定(bind)

c# - 使用字符串或数组从 C# 访问 XAML 元素

c# - 将 silverlight 类库更改为 wpf 类库