The other day I was playing around with WPF in Visual Studio 2008 and I stumbled across some strange behaviour. I made a mistake in the XAML of a WFP Window.
<Button Background="LightBlueX" Name="button1" Click="button1_Click">Click here</Button>
As you can see the name of the Background color is not valid. Now as long as you have the Window opened in the designer the errorlist will display an error to inform you about the mistake. However, if you try and compile your project, you'll find that the compiler will succesfully build. Then when you run the application you'll get a runtime error (a XAML parse exception). Thinking this to be an error in the compiler I logged a bug on MSConnect.
I received the following feedback:
Hi MarkThanks for your report. The behavior you're reporting is actually by-design - it arises because of a trade off of complexity/performance in the build/compilation process vs surfacing all possible failures at compile time.Errors in XAML attribute values like the one mentioned in the bug are one of the class of errors that can't be picked up with certainty by the build process without loading the entire context of the WPF application being built - this is too heavy an overhead to impose on the compilation process and would cause a major performance degradation in building. The expected process is that the user will use the designer (which of necessity loads a lot more of the context) to locate and eliminate errors of this sort. Hence the fact that the errors list shows the error as described in the repro steps.Thanks for taking the time to submit the issue - I hope you continue to find the designer useful and would welcome any further feedback you have.Mark Wilson-ThomasProgram ManagerWPF Designer Team, Developer Division
Ok, that clarifies things. I'll get into the habit of checking my errorlist before saving a XAML file.