views:

63

answers:

1

Hi all, i am looking to extend a third party control, it is a ComboBox (so it isn't the standard Silverlight one, but that shouldn't matter for this question). To do this, i add a new template control to my controls project, then i change the new control to inherit from ComboBox instead of Control. A style has been created for me in the generic.xaml file, so i delete the default border stuff that was inserted, and then add a property setter for the PopupTemplate.

My problem is that when doing it this way, the combobox doesn't (visibly) render in the silverlight application anymore. However, in the constructor of my extension if i comment out the line

this.DefaultStyleKey = typeof(MyComboBox);

and put the PopupTemplate xaml bit in the main silverlight page, it renders correctly. I want the popup template to be declared within the control library, but does this mean that i also have to define the regular Template property? Am i wrong in thinking that anything i don't explicitly specify should just be inherited from the base control?

A: 

A control can only have one default style. You need to copy the entire default style of the base control into the Generic.Xaml for you new MyComboBox then adjust it accordingly.

AnthonyWJones
Yep, I had to copy the entire style for the base control - but i was able to put all that into a separate xaml resource dictionary dedicated to just my control, and then just link it back in to the generic.xaml using *ResourceDictionary.MergedDictionaries* to reference my separate file.
slugster