As you might have seen in the "WPF Style Hell" piece, I have been struggling a bit with WPF and the XAML markup. While Microsoft wants XAML to become the next generation (read replacement for) windows forms, I have found editing XAML in Visual Studio 2008 to be a pain. Errors showing up which cannot be traced back to the source, markup that has to be written a specific way for some attributes, while others can be done however you like.
For my first problem, I resorted to Google and MSDN as always, but after running out of ideas, I decided to post on the MSDN forums where there is an area dedicated to Windows Presentation Foundation. Within a few hours, a fellow community member gave the right answer, revealing what to me looks like a bug.
After reworking the code, finding my way around WPF and trying to make it easy to read and reusable, I decided to place some of the code I created in a WPF User Control, which I thought would come in handy when doing more WPF stuff.
Then the next problem came. As before, everything rendered in the designer (for the user control), but when adding it to the application, an error comes up which I could not trace back to anything I did. So, back to Google, MSDN, and after that, the MSDN WPF forum.
After a few comments, I found out I had a small error in the code and learned more about User Controls; setting the Name property has to be done via x:Name. To bad that it didn't solve the problem. While I know it's hard to solve problems based on partial code, I decided to just zip up my Solution and put it on my web space so that people who wanted to help could see the full code. I also added that the zip is 520kb so that people know how big the download is, which as you can see, is peanuts in modern day broadband internet land.
After receiving a Microsoft Alert that Charles Petzold had replied, I was overjoyed. I know his name from the InTrack session at Microsoft I had visited last week, know he has written a book on WPF and that he helps out on the WPF forum on a regular basis... that all changed when I saw what he had replied. Nothing based on the context, just a Troll about my comment that I was using VB.NET for the code behind (which I posted as a response to people referring to C# code and the fact that there wasn't a namespace mentioned in the pieces of code I posted) and that every .NET programmer should be able to read C#. He was also unhappy with the BIG 520kb download, which he sees as an insult to the people who try to help because I force them to download such a big file.
Right now, I'm just about to give up on XAML for a while, since I only gave it a go for fun and because I can see the power if you use it correctly. The fact that I'm a programmer, not a graphical designer, is against me, most people will just use Blend to create their XAML while I want to do it by code, which is something Visual Studio 2008 just doesn't seem to be equipped for in its current form.
Update @ 25th of January 2008:
After reading a somewhat related bug on Microsoft Connect (Microsoft Bug Reporting website), I decided to remove all Style="{StaticResource StyleName}" entries, which resulted in a compiling and running application for once! While I wasn't really happy to resort back to not using styles in UserControls, I decided to try and see if there was a <UserControl.Resources> tag available. After seeing that it was available, I copied the style from the <Application.Resources> into the UserControl's Resources tag and pasta presto: working code again.
It seems like UserControls are totally isolated for some reason, yet Visual Studio Team System 2008 doesn't seem to be aware of this fact. You'd expect an error or warning telling you what you did wrong. It worked for the three previous versions of Visual Studio, why not with the 2008 version? I just hope they take a look at this, and issue a service pack fixing the IDE.