RadMenuItem - No longer able to set the "Template" property...

6 posts, 0 answers
  1. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 16 Apr 2012 Link to this post

    Hello,

    Recently I upgraded to the latest dll's (2012.1.0326.1040) and have noticed a regression with RadMenuItem's.  

    I was able to define a RadContextMenu like this (specifically note the "Template" property on "rmi1"):

    <ToggleButton x:Name="tb" Content="xxxx" Height="30" Width="100" IsChecked="{Binding IsOpen, ElementName=rcm, Mode=TwoWay}">
      <telerik:RadContextMenu.ContextMenu>
        <telerik:RadContextMenu x:Name="rcm" >
          <telerik:RadMenuItem x:Name="rmi1" Header="rmi1" Template="{StaticResource AControlTemplate}" />
        </telerik:RadContextMenu>
      </telerik:RadContextMenu.ContextMenu>
    </ToggleButton>


    Now after the update, this no longer works.  Has anybody else noticed this issue?

    Thanks,
    Rob
  2. Matthias Bibo
    Matthias Bibo avatar
    72 posts
    Member since:
    Mar 2010

    Posted 19 Apr 2012 Link to this post

    Hello,

    yes, I have encountered a problem with templated menuitems.

    I have a RadcontextMenu with a templated Sub-ContextMenu, which does not work anymore after the upgrade.

    <bdlControls:BDLMenuItem Header="Neuer Kontakt" ItemsSource="{Binding KontaktArten}">
      <bdlControls:BDLMenuItem.ItemTemplate>
        <DataTemplate>
            <bdlControls:BDLMenuItem BdlCommands:RadMenuItemClick.Command="{Binding Path=DataSource.CreateNeuesKontaktCommand, Source={StaticResource DataContextProxy}}" BdlCommands:RadMenuItemClick.CommandParameter="{Binding}">
                <bdlControls:BDLMenuItem.Template>
                    <ControlTemplate>
                        <TextBlock Text="{Binding Name}" Foreground="{Binding Path=IsEnabled, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource KontaktEnabledColorConverter} }"/>
                    </ControlTemplate>
                </bdlControls:BDLMenuItem.Template>
            </bdlControls:BDLMenuItem>
        </DataTemplate>
      </bdlControls:BDLMenuItem.ItemTemplate>  
    </bdlControls:BDLMenuItem>                                       

  3. DevCraft banner
  4. Dani
    Admin
    Dani avatar
    848 posts

    Posted 20 Apr 2012 Link to this post

    Hi Rob, Matthias,

    Setting a custom Template as a StaticResource is indeed non-functional since 2012 Q1 release. However, this functionality was never intended to work in this particular manner. Basically, the RadMenuItem has four different tempaltes and code determines what template is to be used depending on the role that the menu item has (TopLevelHeader, TopLevelItem, SubMenuHeader, SubMenuItem). So whenever some retemplating work should be done, it should be done through the Style property (RadMenuItemStyle) and it should contain all four templates. The menu item will pick up the needed template according to its role.

    Retemplating in the way you suggest did work in previous versions of RadMenu. However, I am afraid this was not intended behavior, but rather a result of issues that the control had in SIlverlight. The 2012 Q1 release introduced some bug fixes for RadMenu and as a result the templating process started working as it was initially design to. I am sorry to hear that this affected your customizations in an undesired way. I suggest you apply customizations through the RadMenuItemStyle.

    Let me know if you need some guidance on styling the RadMenuItem.


    All the best,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  5. Matthias Bibo
    Matthias Bibo avatar
    72 posts
    Member since:
    Mar 2010

    Posted 20 Apr 2012 Link to this post

    Hello,

    but Templating is an elementary basic of the Silverlight/WPF GUI concept  and it works on every control/item, or?

    It worked very well in your Menu for years (and of course we used it) and now you removed it during a "bugfix"?

    We have broken contextmenues in our application and cannot deliver anymore until it is repaired!

    But when you say it is possible with styles, and you give us guidance how we can solve our issue.

    Why we used templating in menuitems?

    We have nested dynamic contextmenues (with/without icons) binded by an Itemsource. 

    Each menuitem needs to have a command , for executing an action in the viewmodel.

    How can this be solved by using the four gloabl styles? Can you give us an XAML example based on out example?

    Regards,

    BDL

  6. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 20 Apr 2012 Link to this post

    I was able to get past it by creating a style with that template and setting that on the RadMenuItem.  Seems to work...
  7. Dani
    Admin
    Dani avatar
    848 posts

    Posted 23 Apr 2012 Link to this post

    Hi Matthias, Rob

    Matthias, you are right - templating is essential. The four templates of RadMenuItem serve as a means to have differently looking menu items depending on their position, which is also essential for the control. So, to recreate the same behavior you originally had, RadMenuItemStyle should be used.

    Attached is a sample. Hope it helps.

    Rob, I am glad you managed to get it working.

    Let me know if you need any help.

    Regards,
    Dani
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Back to Top
DevCraft banner