Configuring the RadPane's Menu

9 posts, 0 answers
  1. CS
    CS avatar
    16 posts
    Member since:
    Apr 2008

    Posted 17 Mar 2010 Link to this post

    Hello,

    I just upgraded to version Q1 2010.  In order to hide the existing menu items in a radpane and add a custom menu item I was using code similar to the following:

    RadPane.MenuCommands.Clear();
    RadPane.MenuCommands.Add(mycustommenucommand);

    But with Q1 2010 the MenuCommands property of the RadPane object is null and the help says that it is deprecated.  How do I hide the existing menu commands and add a custom menu command now?

    Thanks,
    Craig
  2. zhao judi
    zhao judi avatar
    2 posts
    Member since:
    Oct 2012

    Posted 18 Mar 2010 Link to this post

    I meet the same trouble, anyone can help on this issue?
    Thanks!
  3. DevCraft banner
  4. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 18 Mar 2010 Link to this post

    Hi ,

    You can customize the drop down menu by changing the ContextMenuTemplate property of the RadPane control. Please, find the attached project that demonstrates the approach (the demo uses commands, but you could implement it however you like to).

    Regards,
    Rosi
    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.
  5. Yao
    Yao avatar
    8 posts
    Member since:
    May 2010

    Posted 04 Jun 2010 Link to this post

    hi admin , i got a bug by your way of custom....

    {System.Reflection.TargetInvocationException: 调用的目标发生了异常。 ---> System.InvalidCastException: 无法将类型为“System.Windows.Controls.ContentControl”的对象强制转换为类型“Telerik.Windows.Controls.RadPane”。
       位于 FlashFoolWarn.Views.MeetingCenter.UrgentPlanManageMap.InitializeComponent()
       位于 FlashFoolWarn.Views.MeetingCenter.UrgentPlanManageMap..ctor()
       --- 内部异常堆栈跟踪的结尾 ---
       位于 System.Windows.Navigation.PageResourceContentLoader.EndLoad(IAsyncResult asyncResult)
       位于 System.Windows.Navigation.NavigationService.ContentLoader_BeginLoad_Callback(IAsyncResult result)}
  6. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 09 Jun 2010 Link to this post

    Hi y y,

     Could you please give us some more information about the your scenario and the version of RadControls for Silverlight you use? If you could send us a sample project that reproduces the problem this would be of great help.

    Kind regards,
    Miroslav Nedyalkov
    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.
  7. Pat
    Pat avatar
    5 posts
    Member since:
    Jun 2010

    Posted 15 Jul 2010 Link to this post

    Hello,

    Is there a way to control the RadDocking from the C# code and not the xmal?  I was following the localization example for the RadDocking and ran into the same problem as Criag identified below. But the DockingMenu example you included in that thread was all done within the xaml and we would like a solution from within C# code. 

    The ContextMenuTemplate has very few options to use with C#.  The only one I can get to work in the

    ContextMenuTemplate which as you know removes the RadDocking control entirely.

    Another way of asking my question, can you implement the following code from your example using ContestMenuTemplate?

           pane.MenuCommands.Clear();
           // FloatingMenuCommand
           
    pane.MenuCommands.Add( new MyCommand
           {
               HeaderExpression = p =>
    "Floating[localized]",
               IsCheckedExpression = p => p.IsFloating && !p.IsDockable,
               IsEnabledExpression = p => p.IsPinned && p.CanFloat,
               ItemClickAction = p => p.MakeFloatingOnly()
           } );
           
    // DockableMenuCommand
           
    pane.MenuCommands.Add( new MyCommand
           {
               HeaderExpression = p =>
    "Dockable[localized]",
               IsCheckedExpression = p => p.IsDockable && p.IsPinned && !p.IsInDocumentHost,
               IsEnabledExpression = p => p.IsPinned && ( !p.IsInDocumentHost || p.CanFloat ),
               ItemClickAction = p => p.MakeDockable()
           } );
           
    // TabbedDocumentMenuCommand
           
    pane.MenuCommands.Add( new MyCommand
           {
               HeaderExpression = p =>
    "TabbedDocument[localized]",
               IsCheckedExpression = p => p.IsInDocumentHost,
               IsEnabledExpression = p => p.IsPinned && p.CanDockInDocumentHost,
               ItemClickAction = p => p.MoveToDocumentHost()
           } );
           
    // AutoHideMenuCommand
           
    pane.MenuCommands.Add( new MyCommand
           {
               HeaderExpression = p =>
    "AutoHide[localized]",
               IsCheckedExpression = p => !p.IsPinned,
               IsEnabledExpression = p => !p.IsFloating && !p.IsInDocumentHost && p.CanUserPin,
               ItemClickAction = p => p.IsPinned = !p.IsPinned
           } );
           
    // CloseMenuCommand
           
    pane.MenuCommands.Add( new MyCommand
           {
               HeaderExpression = p =>
    "Close[localized]",
               IsCheckedExpression = p => p.IsHidden,
               IsEnabledExpression = p => p.CanUserClose,
               ItemClickAction = p => p.IsHidden = true
           } );
           
    foreach ( var mc in pane.MenuCommands )
           {
               mc.NotifyPaneStateChange( pane );
           }

  8. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 20 Jul 2010 Link to this post

    Hello Pat,

     You could manipulate the context menu generated through the ContextMenuTemplate using the following code:

    RadContextMenu menu;
     
    private void RadContextMenu_Loaded(object sender, RoutedEventArgs e)
    {
        if (menu == null)
        {
            menu = sender as RadContextMenu;
            menu.Items.Add("Menu item 1");
        }
    }
    and the following XAML:
    <telerik:RadPane x:Name="pane" Header="pane">
        <telerik:RadPane.ContextMenuTemplate>
            <DataTemplate>
                <telerik:RadContextMenu Loaded="RadContextMenu_Loaded">
                    <telerik:RadMenuItem Header="item" />
                </telerik:RadContextMenu>
            </DataTemplate>
        </telerik:RadPane.ContextMenuTemplate>
    ...
    </telerik:RadPane>

    Hope this information helps!

    Sincerely yours,
    Miroslav Nedyalkov
    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
  9. Andrew
    Andrew avatar
    29 posts
    Member since:
    Oct 2010

    Posted 23 Dec 2011 Link to this post

    Isn't there a simple way of adding a command without creating your own data templates etc? It is a clear overkill when all you want to do is is execute some code when user clicks on that menu item.
  10. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 28 Dec 2011 Link to this post

    Hello,

    Unfortunately the only way to change the ContextMenu of the RadPane is to use a DataTemplate, however it is not needed to use RadContextMenu Loaded event as it is shown in the previous post but you can just set a Command to the added menu item. More info and code samples on how to do this you can find in this help article.

    Kind regards,
    Boyan
    the Telerik team

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

Back to Top
DevCraft banner