This is a migrated thread and some comments may be shown as answers.

Specific apparences for custom objects

4 Answers 87 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
Julien
Top achievements
Rank 1
Julien asked on 01 Sep 2009, 07:48 PM
I created a custom button that inherits from RadButton. I am able to inherit the theme of the RadButton by overriding the ThemeClassName like shown in your Knowledge Base. However, that's not what I want to do. Here is the override I have done :

class MathButton : RadButton{
    public override string ThemeClassName{
        get{return "WindowsApplication1.MathButton";}
    }
}

My theme gives an appearence to all the buttons of the RadButton type, but I don't want the MathButton to inherit the RadButton appearence. I would want to be able to have a different appearence for each type of button I create from the RadButton type. I want all the button appearences to be in the same theme.

Is there a way to do that?

 

 

 

 

4 Answers, 1 is accepted

Sort by
0
Julien
Top achievements
Rank 1
answered on 02 Sep 2009, 09:08 PM
I seem to have found a way to do it. I have a xml file for my my normal button and a xml file for my MathButton. In the xml file of the MathButton, there a line :

<RadStylesheetRelation ControlType="Telerik.WinControls.UI.RadButton" ElementType="Telerik.WinControls.RootRadElement" />

 


I changed it for :

<RadStylesheetRelation ControlType="WindowsApplication1.Mathbutton" ElementType="Telerik.WinControls.RootRadElement" />


And it seems to work. However, is there way other than manually change the ControlType in the xml file?
0
Nikolay
Telerik team
answered on 04 Sep 2009, 04:30 PM
Hello Julien,

There is a way by which the type of your custom control can be serialized in the xml theme. You should create a class library project and implement your custom controls there. Then, you should load the types by the main menu - File >> Load Control >> From Assembly. Please note that custom designers should be created and assigned to your custom controls. These designers will be loaded in Visual Style Builder when you want to load your control. When you save a theme, it will be saved with the desired relations. Please note that by following this approach you will lose the predefined ControlDefault theme settings.

I am attaching a sample project which demonstrates how you should implement your custom controls and the designers.

I hope this helps. If you have additional questions, feel free to contact me.

Greetings,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Julien
Top achievements
Rank 1
answered on 04 Sep 2009, 05:44 PM
Thank you for your answer.

I must be doing something wrong because I tried to load my type from the Assembly before (and tried again just now) and it didn't work.

I load from the Assembly, select the WindowsApplication1.exe from the debug folder, the list of my custom controls is displayed and I select one, then a button appear for me to modify. Once I'm finished, I save the theme but the ContolType is still Telerik.WinControls.UI.RadButton, not the custom control type.

I saw in your exemple that the ControlType in the theme files was the custom control's name, but the way I'm doing it, it doesn't seem to want to save that way.

Is there something I forgot to do?
0
Mike
Telerik team
answered on 09 Sep 2009, 03:56 PM
Hi Julien,

The key point in order to make this work is the class HistoryButtonDesignTimeData (from the project attached previously) and the corresponding attribute on the custom button class:
[RadThemeDesignerData(typeof(HistoryButtonDesignTimeData))] 
    public class HistoryButton : RadButton 

Please check if you are using the same approach, rebuild your app, restart VS and try again the same steps with VSB. I hope this helps.

Regards,
Mike
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Themes and Visual Style Builder
Asked by
Julien
Top achievements
Rank 1
Answers by
Julien
Top achievements
Rank 1
Nikolay
Telerik team
Mike
Telerik team
Share this question
or