0

当我尝试使用UserControl同一解决方案中的 a 时,我正在NullPointerException排队InitializeComponent()

MainWindow.xaml.cs要添加的文件UserControl

ViewStudentUc viewStudentUc = new ViewStudentUc();
viewStudentGrid.Children.Add(viewStudentUc);

ViewStudentUc.xaml遇到异常的文件:

public ViewStudentUc()
{
    InitializeComponent();   //Where I'm getting NullPointerException.
}

为什么我会收到此异常以及如何删除它?

这是调用堆栈。

SNS School Management.exe!SNS_School_Management.ViewStudentUc.ViewStudentUc() Line 25   C#
SNS School Management.exe!SNS_School_Management.MainWindow.viewStudent_button_Click(object sender, System.Windows.RoutedEventArgs e) Line 39 + 0x15 bytes   C#
[External Code] 
4

0 回答 0