Specific apparences for custom objects

5 posts, 0 answers
  1. Julien
    Julien avatar
    24 posts
    Member since:
    Nov 2008

    Posted 01 Sep 2009 Link to this post

    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?

     

     

     

     

  2. Julien
    Julien avatar
    24 posts
    Member since:
    Nov 2008

    Posted 02 Sep 2009 Link to this post

    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?
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 04 Sep 2009 Link to this post

    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.
  5. Julien
    Julien avatar
    24 posts
    Member since:
    Nov 2008

    Posted 04 Sep 2009 Link to this post

    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?
  6. Mike
    Admin
    Mike avatar
    640 posts

    Posted 09 Sep 2009 Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready