I was writing a custom control today - started by using the VS 2005 "Add New Item..." dialog. After providing the filename, it barfed with a message "Value does not fall within the expected range". Obviously the new item wizard doesn't like something about my project. It actually created the code-behind file successfully, but nothing else, so I was left to setup the themes\generic.xaml file myself. Easy enough, right?
Created a simple folder in the project, called it "themes", then created a simple generic.xaml file, which contained a ResourceDictionary. Now when using the custom control from some window, I would get
nothing. argh. Looked at the compile settings for generic.xaml, Build Action "Page", "Do not copy" ... looks good. Struggled around for a bit, then finally compared to another VS 2005 project started from scratch, where the add new item works.
The answer: AssemblyInfo.cs needs a ThemeInfo attribute.
Mine looks like this (sans comments), and it all seems to work now...
[assembly: ThemeInfo(
ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly )]