Restoring layout on menu items?

2 Answers 71 Views
Menu
Willy
Top achievements
Rank 2
Iron
Iron
Willy asked on 16 Mar 2023, 05:22 PM

Hello, 

I need to change the colors of an item on my menu to bring attention to it. That part works great. Where I am having trouble is resetting it back to defaults. I am trying to use the resetvalue function to do this? Am I doing this correctly? 

With mnuForms
                .Image = My.Resources.rejectedForms16x16
                .BorderPrimitive.Visibility = ElementVisibility.Visible
                .FillPrimitive.GradientStyle = GradientStyles.Solid
                .FillPrimitive.BackColor = Color.Red
                .ForeColor = Color.White

                .ResetValue(FillPrimitive.GradientStyleProperty, ValueResetFlags.Local)
                .ResetValue(FillPrimitive.BackColorProperty, ValueResetFlags.Local)
                .ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local)
                .ResetValue(BorderPrimitive.VisibilityProperty, ValueResetFlags.Local)

End With

2 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 Mar 2023, 06:15 AM

Hello, Bill,

Please have in mind that depending on the theme that is applied to RadMenu, it may be possible to observe a different look with one and the same code. The following article gives useful information how to override theme settings at run time:

https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/override-theme-settings-at-run-time 

In case you are still experiencing any further difficulties, it would be greatly appreciated if you can specify what is the exact goal that you are trying to achieve. Thus, we would be able to get better understanding of the precise case and provide further assistance.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Willy
Top achievements
Rank 2
Iron
Iron
commented on 21 Mar 2023, 01:37 PM

Hi Dess, I am just trying to reset the colors I changed back to their default values. I just need to temporarily highlight a menu item  as per the code I posted. 

 

  .Image = My.Resources.rejectedForms16x16
                .BorderPrimitive.Visibility = ElementVisibility.Visible
                .FillPrimitive.GradientStyle = GradientStyles.Solid
                .FillPrimitive.BackColor = Color.Red
                .ForeColor = Color.White

 

and then change it back to all defaults when I am no longer needing to highlight it.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 23 Mar 2023, 12:44 PM

Hi, Bill,

I have prepared a sample code snippet how to set and reset the style settings. More information about the used approach is demonstrated here: 

https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/override-theme-settings-at-run-time 

    Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
        Me.RadMenuItem1.SetThemeValueOverride(Telerik.WinControls.Primitives.FillPrimitive.BackColorProperty, Color.Red, "", GetType(Telerik.WinControls.Primitives.FillPrimitive))
        Me.RadMenuItem1.SetThemeValueOverride(Telerik.WinControls.Primitives.FillPrimitive.GradientStyleProperty, GradientStyles.Solid, "", GetType(Telerik.WinControls.Primitives.FillPrimitive))
        Me.RadMenuItem1.SetThemeValueOverride(LightVisualElement.ForeColorProperty, Color.White, "")
        Me.RadMenuItem1.SetThemeValueOverride(LightVisualElement.ImageProperty, My.Resources.Folder1, "")
        Me.RadMenuItem1.SetThemeValueOverride(Telerik.WinControls.Primitives.BorderPrimitive.VisibilityProperty, ElementVisibility.Visible, "")
    End Sub

    Private Sub RadButton2_Click(sender As Object, e As EventArgs) Handles RadButton2.Click
        Me.RadMenuItem1.ResetThemeValueOverride(Telerik.WinControls.Primitives.FillPrimitive.BackColorProperty, "")
        Me.RadMenuItem1.ResetThemeValueOverride(Telerik.WinControls.Primitives.FillPrimitive.GradientStyleProperty, "")

        Me.RadMenuItem1.ResetThemeValueOverride(LightVisualElement.ForeColorProperty, "")
        Me.RadMenuItem1.ResetThemeValueOverride(LightVisualElement.ImageProperty, "")
        Me.RadMenuItem1.ResetThemeValueOverride(LightVisualElement.DrawBorderProperty, "")
        Me.RadMenuItem1.ResetThemeValueOverride(Telerik.WinControls.Primitives.BorderPrimitive.VisibilityProperty, "")
    End Sub

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Menu
Asked by
Willy
Top achievements
Rank 2
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or