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

Configuring the RadPane's Menu

8 Answers 198 Views
Docking
This is a migrated thread and some comments may be shown as answers.
CS
Top achievements
Rank 1
CS asked on 17 Mar 2010, 07:47 PM
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

8 Answers, 1 is accepted

Sort by
0
zhao judi
Top achievements
Rank 1
answered on 18 Mar 2010, 07:28 AM
I meet the same trouble, anyone can help on this issue?
Thanks!
0
Rosi
Telerik team
answered on 18 Mar 2010, 01:19 PM
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.
0
Yao
Top achievements
Rank 1
answered on 04 Jun 2010, 08:10 AM
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)}
0
Miroslav Nedyalkov
Telerik team
answered on 09 Jun 2010, 09:21 AM
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.
0
Pat
Top achievements
Rank 1
answered on 15 Jul 2010, 06:44 PM
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 );
       }

0
Miroslav Nedyalkov
Telerik team
answered on 20 Jul 2010, 11:09 AM
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
0
Andrew
Top achievements
Rank 1
answered on 23 Dec 2011, 11:41 PM
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.
0
Boyan
Telerik team
answered on 28 Dec 2011, 11:02 AM
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 >>

Tags
Docking
Asked by
CS
Top achievements
Rank 1
Answers by
zhao judi
Top achievements
Rank 1
Rosi
Telerik team
Yao
Top achievements
Rank 1
Miroslav Nedyalkov
Telerik team
Pat
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Boyan
Telerik team
Share this question
or