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

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

5 Answers 125 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rob
Top achievements
Rank 1
Rob asked on 16 Apr 2012, 09:29 PM
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

5 Answers, 1 is accepted

Sort by
0
Matthias Bibo
Top achievements
Rank 1
answered on 19 Apr 2012, 01:02 PM

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>                                       

0
Dani
Telerik team
answered on 20 Apr 2012, 10:25 AM
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 >>
0
Matthias Bibo
Top achievements
Rank 1
answered on 20 Apr 2012, 11:11 AM

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

0
Rob
Top achievements
Rank 1
answered on 20 Apr 2012, 01:03 PM
I was able to get past it by creating a style with that template and setting that on the RadMenuItem.  Seems to work...
0
Dani
Telerik team
answered on 23 Apr 2012, 12:51 PM
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 >>
Tags
Menu
Asked by
Rob
Top achievements
Rank 1
Answers by
Matthias Bibo
Top achievements
Rank 1
Dani
Telerik team
Rob
Top achievements
Rank 1
Share this question
or