Is it possible to have an assembly with embedded themes, then reference that assembly across different projects in the same solution. Then using the radthememangaer - Load Themes from Resource - point to the compiled assembly.
My UI is split across different projects. How can I share the same themes across multiple projects?
P
12 Answers, 1 is accepted
Thank you for this question.
Your scenario is possible. Please refer to the following Knowledge Base article for additional information: Creating a theme component. Note that you do not need RadThemeManager in this case.
I hope this helps. If you have additional questions, feel free to contact me.
Greetings,
Nikolay
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
This sounds great, I am trying it out now. While I am doing this, what standard should you adopt when creating themes? For example:- In the sample that you supplied you have two xml files, one for the listbox and the other for the scrollBar,
1, could you just create on XML file with both the ListBox and scrollbar combined?
2, could I have multiple class in my component with different themes?
3, I have a requirement that a label has two themes - would this be achieved in two separate xml files?
Thanks
K
I added your 'desert' theme to my designer surface, I then applied the theme to a label, I then removed the theme, however the theme still appears in the smart tag of the label. How can I clear this option from my smart tag?
Thanks
P
Thank you for getting back to us.
Please find the answers to your questions below:
- Yes, you can create just one theme for RadListBox and its scrollbars. In the sample project provided, the ListBox.xml theme contains settings for both RadListBox and its scrollbars. The ScrollBar.xml theme is needed only for the RadVScrollBar right aligned on the form.
- In your theme project you can have several .cs files representing the components.
- For the different themes for one control you should create separate theme files.
Regarding your last question, the themes' registrations are kept in the Visual Studio's static memory. So, in order to remove the option from the smart tag, you should close and then reopen Visual Studio. This will clear its memory.
If you have additional questions, feel free to contact me.
Nikolay
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I have created two theme files CMXLabel.xml and CMXLabelHeader.xml. Using your std way of accessing theme through a component I have made the following entries.
ThemeResolutionService.RegisterThemeFromStorage(ThemeStorageType.Resource,
"FTS.CMX.Themes.CMXLabel.xml")
ThemeResolutionService.RegisterThemeFromStorage(ThemeStorageType.Resource,
"FTS.CMX.Themes.CMXLabelHeader.xml")
Both of these files are compiled as an embedded resource
CMXLabel has a font of Tahoma 9 pt
CMXLabelHeader has a font of Tahoma 9pt bold
First of all CMXLabelHeader does NOT show up in my smart tags for a radLabel.
Secondly CMXLabel does show up in my smart tags, which I applied a theme, OK. Now.... I changed the CMXLabel theme again using your visual style builder tool to change the font to 8.25pt, saved the file, recompiled my component, rebuilt my project, went to my label, reset the ThemeName, reapplied the CMXLabel theme and it did NOT change the theme. In fact using the reset does not seem to do anything AT ALL. I am seem to be stuck with this theme.
P
Regarding your first issue, please make sure that your theme files have different ThemeNames. Otherwise, if the theme files have the one and the same ThemeName, you will not be able to see the choices in the ThemeName dropdown. I am attaching a movie where the correct behavior is demonstrated.
As to your second issue, where the changes are not applied at design-time, I was able to reproduce it. It will be addressed in one of our next versions. For the time being, you can get the appearance updated by closing and then reopening Visual Studio.
I have updated your Telerik points account for the report. If you have additional questions, feel free to contact me.
Best wishes,
Nikolay
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I have created the class library as the linke (Creating a theme component) stated, then have compiled the project and my Theme.dll was created but still I can't find and see the theme component in the toolbox.
Could you please help me why I can't do this?
Thanks
In order to be able to assist you with a helpful response, I will need a sample project of yours which demonstrates how exactly the theme component is created. Please open a new support ticket and send the sample project there.
Note that according to your current Visual Studio settings, a component may not be automatically loaded in the Toolbox. In that case, from the main Visual Studio menu you need to choose Project >> Refresh Project Toolbox Items.
Regards,
Nikolay
the Telerik team
Is it possible to use theme package instead of theme XMLs in order to create theme component?
I will refresh toolbox and hope to work.
Regards
Yes, you can use a theme package file (*tssp) in the theme class library. In order to load the theme package file in the library, however, you need to use a slightly different code snippet:
[ToolboxItem(
true
)]
public
class
Office2010BlueTheme : RadThemeComponentBase
{
static
bool
loaded =
false
;
public
Office2010BlueTheme()
{
ThemeRepository.RegisterTheme(
this
);
}
public
override
void
Load()
{
if
(!loaded || IsDesignMode)
{
loaded =
true
;
Assembly resourceAssembly =
typeof
(Office2010BlueTheme).Assembly;
LoadResource(resourceAssembly,
"Telerik.WinControls.Themes.Office2010Blue.tssp"
);
}
}
public
override
string
ThemeName
{
get
{
return
"Office2010Blue"
;
}
}
}
This is how the Office2010BlueTheme component is made. There, the file name of the tssp file is Office2010Blue.tssp and the default namespace of the class library project is Telerik.WinControls.Themes. Again, the Build Action of the tssp file should be set to Embedded Resource.
I hope this helps.
Greetings,
Nikolay
the Telerik team
Ok, I looked further down and found a sample. Will try that one.. sorry.. :-)
I am glad to hear that you have found a sample that covers the case. If you still experience any issues, please open a new support ticket and send me a sample project which demonstrates the described behavior. This will allow me to assist you further with an adequate response.
Greetings,Nikolay
the Telerik team