Override a theme, change the backcolor of a RadMenuItem

4 posts, 0 answers
  1. Susann
    Susann avatar
    5 posts
    Member since:
    Mar 2015

    Posted 18 May 2015 Link to this post

    Hello,

    for my application I created with the Visual Style Builder own theme, which I put by this code throughout the application:

    ThemeResolutionService.LoadPackageFile("MyTheme.tssp");
    ThemeResolutionService.ApplicationThemeName = "MyTheme";

    In it I also designed the RadMenuItems. Now I would like but the background color of a ContextMenuItems (RadMenuItem) in the code change to be able to override the theme. Unfortunately it is not possible to customize the background color. With the foreground color it works.
    Can anyone help me.

    Thank you.

  2. Susann
    Susann avatar
    5 posts
    Member since:
    Mar 2015

    Posted 18 May 2015 in reply to Susann Link to this post

    I want to change the backcolor by mouse over. Is it possible to be able to customize the code.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 20 May 2015 Link to this post

    Hello Susann,

    Thank you for writing.

    You can subscribe to the RadMenuItem.MouseEnter event where you can apply the desired color to the FillPrimitive and reset the color in the RadMenuItem.MouseLeave event:
    public Form1()
    {
        InitializeComponent();
     
        ThemeResolutionService.ApplicationThemeName = "TelerikMetroBlue";
     
        foreach (RadMenuItem item in this.radMenu1.Items)
        {
            WireEvents(item);              
        }
    }
     
    private void WireEvents(RadMenuItem item)
    {
        item.MouseEnter += item_MouseEnter;
        item.MouseLeave += item_MouseLeave;
        foreach (RadMenuItem subItem in item.Items)
        {
            WireEvents(subItem);
        }
    }
     
    private void item_MouseLeave(object sender, EventArgs e)
    {
        RadMenuItem item = sender as RadMenuItem;
        item.FillPrimitive.BackColor = Color.White;
    }
     
    private void item_MouseEnter(object sender, EventArgs e)
    {
        RadMenuItem item = sender as RadMenuItem;
        item.FillPrimitive.BackColor = Color.Aqua;
    }

    I hope this information helps. Should you have further questions, I would be glad to help.
     
    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. Susann
    Susann avatar
    5 posts
    Member since:
    Mar 2015

    Posted 20 May 2015 in reply to Dess Link to this post

    Thanks a lot. It works.
Back to Top