views:

88

answers:

2

I have strange problem with WPF custom control that I have made. When I drag and drop WPF custom control from toolbox to design surface I only see one border without any controls in it... I have another same WPF custom control project with same custom control and same code and when I reference that project everything works fine.

I have template in theme folder that is called DatePicker.Generic.Xaml and I have defined

<Style x:Key="{x:Type DateControls:DatePicker}" 
       TargetType="{x:Type DateControls:DatePicker}">

where DateControls is xml namespace of my DatePicker custom control. I have also added

[assembly: ThemeInfo(
    ResourceDictionaryLocation.SourceAssembly,
    ResourceDictionaryLocation.SourceAssembly)] 

in assemblyinfo file. Can someone help? Thanks

A: 

You may want to look at the ComponentResourceKey Markup Extension. Look at the TypeInTargetAssembly and ResourceId argument (of componentresourcekey)'s when you set the Style element.

RandomNickName42
I have look and everything seems fine. I have several times defined TypeInTargetAssembly={x:Type DateControls:DatePicker},ResourceId=DropDownButtonStyleKey with different ResourceId and DateControls is good namespace...
Radenko Zec
+1  A: 

Check that your control code has a static constructor that calls DefaultStyleKeyProperty.OverrideMetadata with the appropriate type arguments (it's generated for you if you add a new custom control in VS).

John Bowen