Reputation: 1
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
Upvotes: 0
Views: 424
Reputation: 24453
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).
Upvotes: 1
Reputation: 5965
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.
Upvotes: 0