Thursday, May 22, 2008

I always planned on writing work related stuff

Bonus personal info for friends/family - we got a frog, and I discovered I dislike crickets :). I was thankful we had a dustbuster to take care of them.

Two things in working with WPF that took me a while to figure out.

First, I had a bug where _'s were going missing in a button's label. I'd read about the keyboard accelerator stuff, but it didn't occur to me because I was putting a directory name in there. Quick fix was to make a converter:

public class NoMnemonicConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((string)value).Replace("_", "__");
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((string)value).Replace("__", "_");
}
}

Second, I was trying to put some of my common controls and some I'd borrowed from others into a single library. My generic ResourceDictionary just would not get recognized. I googled and grepped until my eyes fell out, then I found this segment to put into the library's AssemblyInfo.cs:


[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]


What a relief!