我有一个WPF应用程序,其中我使用了多个窗体。有一个主窗体,在启动应用程序时打开,称为MainWindow.xaml
。然后,根据用户选项,该窗体会打开多个窗体。有一个窗体StartClassWindow.xaml
。目前,我正在处理这个窗体,所以我希望它可以直接启动,而不是MainWindow.xaml
。因此,我更改了app.xaml startupuri
:
<Application x:Class="Class.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
DispatcherUnhandledException="Application_DispatcherUnhandledException"
StartupUri="StartClassWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
但后来它开始产生以下错误:
在类型“Class.StartClassWindow”上找不到匹配的构造函数。您可以使用Arguments或FactoryMethod指令来构造此类型。行号为“3”,行位置为“9”。
这是StartClassWindow.xaml.cs
文件:
namespace Class
{
public partial class StartClassWindow : System.Windows.Window
{
public StartClassWindow(string classData)
{
InitializeComponent();
className = classData;
function();
}
//rest of the code.
}
}
StartupUri
。 - Trương Quốc Khánh