RadMenuItem inheritance display issue

3 posts, 1 answers
  1. Constantinos Petridis
    Constantinos Petridis avatar
    21 posts
    Member since:
    May 2010

    Posted 25 Jun 2010 Link to this post

    I am trying to inherit RadMenuItem (sample bellow), in order to add more properties required by our application.

    Public Class TestMenuItem 
        Inherits RadMenuItem 
        Public Sub New() 
        End Sub 
        Public Sub New(ByVal text As String
            Me.New(text, Nothing
        End Sub 
        Public Sub New(ByVal text As StringByVal tag As Object
            MyBase.New(text, tag) 
        End Sub 
    End Class 

    When I try to add this new RadMenuItem in a RadMenu object, the visual display of the item is different from the actual RadMenuItem. I guess it is a ThemeEngine glitch. Do you have any advice on how to correctly inherit RadMenuItem?

    This is a sample form where two menu items are added, one standard RadMenuItem (test1) and one from the inherited TestMenuItem (test2). Form1 has a RadMenu control added and it is a standard Windows.Form form.
    Public Class Form1 
        Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load 
            Dim mi1 As New RadMenuItem("test1"
            Dim mi2 As New testMenuItem("test2"
        End Sub 
    End Class 

    In the attached image you can see the resulting runtime form with the difference in visual display of the two menu items.

    We are currently evaluating your WinForms controls and we have little to no experience with your libraries :).
  2. Answer
    Deyan avatar
    2026 posts

    Posted 01 Jul 2010 Link to this post

    Hello Constantinos,

    Thanks for contacting us and for your interest in RadControls for WinForms.

    Indeed, the issue that you experience is related to the theming mechanism. Our theming mechanism maps the XML styles to the elements by using their type. So, by inheriting from RadMenuItem, you introduce a new item type which is not recognizable by our mechanism. Thus, you will have to override the ThemeEffectiveType property in your new RadMenuItem type and return the type of RadMenuItem. Take a look at the code snippet below:

    Protected Overrides ReadOnly Property ThemeEffectiveType() As Type
            Return GetType(RadMenuItem)
        End Get
    End Property

    Without this property override, your item will remain unstyled by having the default border and fill colors.

    Consider this as a general approach of avoiding theming issues when inheriting from different items in our framework.

    I hope this helps and will be happy to address any future inquiries regarding our control suite that you might have.

    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
  4. Constantinos Petridis
    Constantinos Petridis avatar
    21 posts
    Member since:
    May 2010

    Posted 01 Jul 2010 Link to this post

    Thank you for your quick answer
    It worked like a charm :)
Back to Top