Reputation: 1467
I have a Silverlight application with a custom control MyDataGrid
which is a DataGrid
with some extra features.
This is part of the project in which it is used. It also requires a custom style. I can add the style to my style resource dictionary and set TargetType="sdk:DataGrid"
which works.
However, my style relies on a property MyProperty
specific to MyDataGrid
, so a warning appears in the editor. More importantly, the styles cannot be previewed in the designer.
They DO work when the code is run, however.
My question is: Is there a way to pull in local controls to a resource dictionary, rather than creating a separate project, compiling it to a .dll, and pulling in that assembly?
Thanks!
Upvotes: 1
Views: 422
Reputation: 6460
It sounds like you made a custom control, but you haven't defined a default style for it. Try the following:
DefaultStyleKey = typeof(MyDataGrid);
If you want to access part of the style (which is defined in XAML) from code, you should name that XAML item as "PART_something". The design tools understand the PART_* syntax plus that's an indication to library consumers that if you retemplate the control, you must define the required pieces prefixed with PART_.
Here are the basics on how to define a custom control.
Upvotes: 1