当我尝试使用同一解决方案中的UserControl
时,我会在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]