Wednesday, October 27, 2010

XAML pages won't generate c# code behind on compile

You'd think Visual Studio would know that if a file ended in ".xaml", then the file.g.cs code that is supposed to be generated from the XAML on compile would always be generated.

Unfortunately for me, I had some significant refactoring to do.  I moved existing XAML files around into new projects, and found that I couldn't compile.  It took me awhile to figure out that the file.g.cs files weren't being generated.  Why they weren't didn't make sense, until a Google search turned up that the properties of these files must be set the Build Action to "page".  Apparently Visual Studio changed the Build Action to something else.  When set to "page", they generated the code correctly.

No comments:

Post a Comment