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

PRISM Adaptor for RadContextMenu

7 Answers 77 Views
RibbonView and RibbonWindow
This is a migrated thread and some comments may be shown as answers.
John Kears
Top achievements
Rank 1
John Kears asked on 10 Jan 2012, 01:32 AM

I would like to dynamically add content to this menu if possible, however when I create a simple Adaptor and add the Region Tag to the XAML code for a RadContectMenu, it never registers it as a valid region. 

Has anyone sucessfully created a PRISM Adaptor for a RadContextMenu?

I get a region for the RadRibbonTab and one for the RadRibbonGroup, but there is not one for the RadContextMenu ...

<telerik:RadRibbonTab Regions:RegionManager.RegionName="ViewTabRibbonRegion"   Name="RibbonTabName_View" Header="View">
              <telerik:RadRibbonGroup Regions:RegionManager.RegionName="ViewTabRibbonGroupCustomRegion" Header="Custom">
                  <telerik:RadRibbonSplitButton Content="test">
                      <telerik:RadRibbonSplitButton.DropDownContent>
                          <telerik:RadContextMenu Name="RadContext" Regions:RegionManager.RegionName="ViewTestContextMenu"  BorderThickness="0">
                          </telerik:RadContextMenu>
                      </telerik:RadRibbonSplitButton.DropDownContent>
                  </telerik:RadRibbonSplitButton >
              </telerik:RadRibbonGroup>
          </telerik:RadRibbonTab>

7 Answers, 1 is accepted

Sort by
0
John Kears
Top achievements
Rank 1
answered on 10 Jan 2012, 07:19 AM
.. further and somewhat related, in that I am updated an inner element .

I can add a RadRibbonButton to the RadRibbonGroup on the outside (i.e. RegionName = "RegionRibbonGroupOuter"), and I see it on the RibbonTab however, when I try to add the same RadRibbonButton instead to the inner RadRibbonGroup (i.e. RegionName = "RegionRibbonGroupWrapped" confined within the RadOrderedWrapPanel) it does seem to locate the Region, but I do not see the Button... 

Unlike the MenuItem issue, this does see the inner Region whereas the MenuItem region (1st post) is not even a valid Region.  I think that is due to it being encapsulated within a DropDownContent, which as far as I can tell is of type object.

<telerik:RadRibbonGroup Header="Ordered Wrap Pannel" Regions:RegionManager.RegionName="RegionRibbonGroupOuter" >
                   <telerik:RadOrderedWrapPanel Regions:RegionManager.RegionName="RegionWrapPanel" >
                       <telerik:RadButtonGroup Regions:RegionManager.RegionName="RegionRibbonGroupWrapped">
                             
                       </telerik:RadButtonGroup>
                          
                   </telerik:RadOrderedWrapPanel>
               </telerik:RadRibbonGroup>
0
John Kears
Top achievements
Rank 1
answered on 10 Jan 2012, 07:22 AM
I am adding to Region in both scenarios to the same RegionManagerInstance and where result.TargetRegion is the name of the two regions mentioned above and ribbonButton is a valid button with image etc..

RegionManagerInstance.AddToRegion(result.TargetRegion, ribbonButton);
0
Tina Stancheva
Telerik team
answered on 12 Jan 2012, 06:38 PM
Hello John,

I wasn't able to reproduce this issue on our side. But if you can send us a solution that reproduces the issue we will definitely further investigate the case.

In the meantime you can examine the attached solution that demonstrates how you can build a RibbonView control by taking advantage of PRISM. It can help you while looking for the cause for your issues.

Also, please keep in mind that the RadContextMenu is designed to be used as a context menu so it expects a right click to open. This is why when this control is used in a RadRibbonSplitButton.DropDownContent it may cause unexpected behavior. Therefore it is better to use the RadMenu control to build the RadRibbonSplitButton.DropDownContent. You can even customize the RadMenu control and its items to look as though you've defined a ContextMenu.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
John Kears
Top achievements
Rank 1
answered on 12 Jan 2012, 07:00 PM
Hi and thank you.

I was able to resolve some of the issues I was having.  Specifically the RadMenuItem with a RadDropDownContent by adding an underlying property to the backing ViewModel for RegionManager and then binding that to the RadContextMenu directly.  I am now able to programatically inject menu items through regionmanager.

The other issue with the RadOrderedWrapPanel is still a bit of a mystery as although I am able to add a RadRibbonButton to the inner RadRibbonButtonGroup, it does not render, but I am almost certain the button is there.  In fact, if I add the same RadRibbonButton to the RadRibbonButtonGroup that encapsulates the RadOrderedWrapPanel element instead I do see the button. 

I will review your attached solution to see if I am missing something obvious or not.

Cheers
0
Tina Stancheva
Telerik team
answered on 17 Jan 2012, 01:56 PM
Hi John,

I just wanted to ask you if the attached solution helped in getting over the issue with the RadOrderedWrapPanel? If it didn't help or you encounter other issues with the Telerik controls, please let us know.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
John Kears
Top achievements
Rank 1
answered on 17 Jan 2012, 02:28 PM
Actually I am able to add a radmenuItem to my context menu progamatically using this approach however the icon is not showing on the menu item.

I have the following binding on the IconTemplate, and I know that there is a valid Image on the underlying ViewModel and I see a call being made to the Getter (Accessor) of that ImageSource property, however the icon does not show up.  The Header is showing up, and the Command binding also works fine (all of which are in the same underlying view model). ...

<telerik:RadMenuItem x:Class="TestTelerik.Controls.RadMenuItemEx"
                 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" mc:Ignorable="d"
                     Header="{Binding Label}" Command="{Binding Command}">
    <telerik:RadMenuItem.IconTemplate>
        <DataTemplate>
            <Image Source="{Binding ImageSource}" Height="16" Width="16"/>
        </DataTemplate>
    </telerik:RadMenuItem.IconTemplate>
</telerik:RadMenuItem>

I also tried to bind to the Image Path instead of ImageSource and it too does not render an image within the context menu.

I am 100% postive that the image is valid. I have other radmenu items that are defined through xaml on that same menu and they do show their respective icons, just not showing the icon for those that I add through prism.
0
John Kears
Top achievements
Rank 1
answered on 17 Jan 2012, 06:05 PM
issue resolved ... needed to add Icon = {binding}  as per below ... works like a charm!

<telerik:RadMenuItem x:Class="TestTelerik.Controls.RadMenuItemEx"
                 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" mc:Ignorable="d"
                     Header="{Binding Label}" Command="{Binding Command}" Icon="{Binding}">
    <telerik:RadMenuItem.IconTemplate>
        <DataTemplate>
            <Image Source="{Binding ImageSource}" Height="16" Width="16"/>
        </DataTemplate>
    </telerik:RadMenuItem.IconTemplate>
</telerik:RadMenuItem>
Tags
RibbonView and RibbonWindow
Asked by
John Kears
Top achievements
Rank 1
Answers by
John Kears
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or