无法创建子窗口

本文关键字:窗口 创建 | 更新日期: 2023-09-27 18:29:34

我正试图在WPF中创建一个子窗口。当点击按钮时,这个子窗口应该会打开

我正在使用通用代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
private void Click_setupClass(object sender, RoutedEventArgs e)
{
    ChildWindow child = new ChildWindow();
}

由于某些原因,无法初始化子窗口。它告诉我找不到Childwindow是不是缺少程序集引用。

childWindow不能通过System.Windows.Controls;访问吗?我做错了什么?

无法创建子窗口

据我所知,

ChildWindow只为Silverlight制作。您应该在WPF中使用Window类。只需调用window.ShowDialog()即可显示模式窗口。