Why won't Generic.xaml work?
The first time I did some control development for Silverlight I ran into a major stumbling block, whatever I put into Generic.xaml just wasn't showing up and none of the tutorials I could find were showing anything different from what I was doing. After some digging through Silverlight with Reflector and a few forum searches show up the culprit ... "DefaultStyleKey".
I'm not sure if this was introduced into later versions of the Silverlight betas but it's certainly not mentioned in a lot of tutorials on the web. OnApplyTemplate uses this key to determine which style to look for in Generic.xaml. This allows you to create controls that inherit from your custom control but still use the same style.
For your control you'll want to override the DefaultStyleKey to the type of your object like follows.
public MyCustomControl()
{
this.DefaultStyleKey = typeof(MyCustomControl);
}
It's tempting to do something like GetType(), but that'll be different for any subclasses so stick with a known type.

Comments
Community Blogs - Sunday, December 14, 2008
Trackback from Community Blogs
Silverlight Cream for December 14, 2008 - 2 -- #455
mgalinks.wordpress.com - Monday, December 15, 2008
Pingback from mgalinks.wordpress.com
2008 December 15 - Links for today « My (almost) Daily Links
Axoraccebra - Monday, September 07, 2009
Oh, Good post.so gald to see your views about resveratrol.I'm also looking for resveratrol supplements. I found a lots of websites online.
and i have read some other idea about resveratrol-anti-aging: , are they true or not?
Anyway, I'll try resveratrol soon.
Biceelentee - Friday, September 25, 2009
Best choice of the week about Crack, Vdts crack, Chem3d crack and War3tft_117a_english crack here http://cracks.goodnano-av.com/
lypeNethy - Thursday, October 15, 2009
Only for you daily news, events and tips about Dildo and Dildo contortionist http://dildo.goodnano-av.com/
enrignfex - Thursday, October 22, 2009
Bookmarked by the billions Dvd site! http://dvd.goodnano-av.com/
Biltapant - Wednesday, October 28, 2009
Best choice of the week about Ebony, Ebony tailpiece, Ebony veneers and Ebony hairstyles. http://ebony.goodnano-av.com/