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

Override a theme, change the backcolor of a RadMenuItem

3 Answers 218 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Susann
Top achievements
Rank 1
Susann asked on 18 May 2015, 11:55 AM

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.

3 Answers, 1 is accepted

Sort by
0
Susann
Top achievements
Rank 1
answered on 18 May 2015, 12:04 PM
I want to change the backcolor by mouse over. Is it possible to be able to customize the code.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 May 2015, 12:05 PM
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
0
Susann
Top achievements
Rank 1
answered on 20 May 2015, 02:00 PM
Thanks a lot. It works.
Tags
Menu
Asked by
Susann
Top achievements
Rank 1
Answers by
Susann
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or