Using a TextBox as an Adorner

I was fooling around with an adorner in a test project and decided to use a TextBox instead of a ComboBox for convenience.  Unfortunately, I found I couldn’t type into the TextBox.  According to Jim Nakashima, this can be addressed by setting the AdornerPanel.IsContentFocusable property, and he’s right.

I am bothered by the “bug” that sends “Delete” input to the designer instead of the TextBox.  I don’t call this a bug, I call it a showstopper.  Oh well, I guess I’ll be able to use TextBox controls in my adorners when we are able to drop VS 2008 support in 5 or 6 years.

Interesting solution to a WPF resource location issue

Design-time is one of my hobbies, and I’ve been fooling around with the WPF designer ("Cider") lately.  I’ve been making adorners do interesting things for the most part and havent fooled around with property editors much, which makes me kind of useless for Blend.

A pattern I’ve been following involves structuring my projects with a folder for each control I’m providing support for.  Each folder has its own resource dictionary in a Resources.xaml file, and the Themes/Generic.xaml includes all of them as a merged resource dictionary.  It works great, but I recently had a problem, couldn’t find the solution, and now that I know what went wrong I want search engines to help others out.

My metadata was loaded correctly, but none of my templates were being applied to adorners.  I thought something was wrong with the merging of the resource dictionaries, so I tried moving a template into Generic.xaml; no dice.  Nothing I did seemed to be making the project pick up the template.  I set up some small proof-of-concept projects, and couldn’t find anything visibly different about what was wrong.  The end of the day arrived and I decided I’d just delete the project and try again tomorrow.

Tomorrow became today, and the project was magically working.  I called a coworker over to witness the event, and he began to point at my project.  "Why do you need that junk in Properties; it’s a class library and you won’t use application settings and resources?"  I agreed; yesterday I’d deleted them too.  In fact, early today I had deleted all of them but our source control decided they were important and resurrected them.  I’m glad it did.

It turns out that in AssemblyInfo.cs, which I clicked on for kicks, there is a ThemeInfoAttribute that tells the project where to find the non-themed and themed resources.  If it’s not there, whatever is supposed to look for Generic.xaml doesn’t look there.  Oops.  When I deleted AssemblyInfo.cs, I broke the theming!

So, if you’re depending on themed or non-themed resources in WPF, don’t delete AssemblyInfo.cs!  Or, if you do, make sure to apply an assembly-level ThemeInfoAttribute somewhere else.  Don’t waste half a day like I did!

Testing Source code posting

Supposedly there’s a markup element for posting code on WordPress blogs.  This is just a test; I’m actually planning some big posts and it will determine if I use the blog or just link to a static page.

public void DoSomething()
{
     MethodCall();
}

Welp, either I did something wrong or WordPress lied to me. I’ll try upgrading this weekend.

*Update:* Turns out I needed to manually install this syntax highlighter.