更改主窗口名称后出错

时间:2021-05-20 19:43:58

I'm using WPF for the first time and I get an error like this:

我第一次使用WPF,我收到这样的错误:

Cannot locate resource 'mainwindow.xaml'

That is becuase I changed the name. Have I missed to change this is some other code? I'm not so familiar with this type of projekt, compared with Windows Form that I used before. Which file launch the application? I have been looking for one in the solution explorer. I guess it's perhaps there the error is?

那是因为我改名了。我错过了改变这是其他一些代码吗?与我之前使用的Windows Form相比,我对这种类型的项目并不熟悉。哪个文件启动应用程序?我一直在寻找解决方案资源管理器中的一个。我想也许错误是?

2 个解决方案

#1


6  

Change it in StartupUri attribute of Application tag in App.xaml also.

也可以在App.xaml中的Application标签的StartupUri属性中更改它。

#2


0  

After renaming a window project item:

重命名窗口项目项后:

  • rename startup URI in App.xaml to corresponding WindowName.xaml;
  • 将App.xaml中的启动URI重命名为相应的WindowName.xaml;

  • check x:Class attribute value in window XAML file, it must be match class name in code behind.
  • 检查x:窗口XAML文件中的类属性值,它必须与后面的代码中的类名匹配。

#1


6  

Change it in StartupUri attribute of Application tag in App.xaml also.

也可以在App.xaml中的Application标签的StartupUri属性中更改它。

#2


0  

After renaming a window project item:

重命名窗口项目项后:

  • rename startup URI in App.xaml to corresponding WindowName.xaml;
  • 将App.xaml中的启动URI重命名为相应的WindowName.xaml;

  • check x:Class attribute value in window XAML file, it must be match class name in code behind.
  • 检查x:窗口XAML文件中的类属性值,它必须与后面的代码中的类名匹配。