wpf程序报"The name 'InitializeComponent' does not exist in the current context"的

stackOverFlow 's answer

I've encountered this a couple times and keep forgetting what causes it. I ran into this when I renamed the namespace on my code behind file but not in my XAML.

So check if you've done the same. They need to match since they are both part of a partial class

namespace ZZZ
{/// <summary>/// Interaction logic for MainWindow.xaml/// </summary>publicpartialclassMainWindow{//...}}<!-- XAML --><Window x:Class="ZZZ.MainWindow">
原文地址:https://www.cnblogs.com/lthxk-yl/p/3161110.html