当我尝试使用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]