I'm using RadControls for WPF Q1 2010 in WPF solution with the MVVM pattern.
When I implemented the RadDock control the ContextMenu of the controls inside the RadPanes stopped showing up. Instead the RadPane context menu pops up with the options: Floating, Dockable etc. If I place the exact same control (StackPanel in my case) in a data tamplate and reference it from the ContentTemplate property of the RadPane as shown below it work fine. This however is not an acceptable workaround in my case. Please help me.
<telerikDocking:RadSplitContainer Orientation="Vertical" InitialPosition="DockedRight"> |
<telerikDocking:RadPaneGroup> |
<telerikDocking:RadPane x:Name="Pane1" Header="Not Working ContextMenu" IsPinned="True" > |
<StackPanel> |
<TextBlock TextWrapping="Wrap" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit."/> |
<StackPanel.ContextMenu> |
<ContextMenu> |
<MenuItem Header="Add" /> |
<MenuItem Header="Edit" /> |
<Separator/> |
<MenuItem Header="Delete" /> |
</ContextMenu> |
</StackPanel.ContextMenu> |
</StackPanel> |
</telerikDocking:RadPane> |
</telerikDocking:RadPaneGroup> |
<telerikDocking:RadPaneGroup> |
<telerikDocking:RadPane Header="Working ContextMenu" IsPinned="True" ContentTemplate="{StaticResource template1}" /> |
</telerikDocking:RadPaneGroup> |
</telerikDocking:RadSplitContainer> |
25 Answers, 1 is accepted
Thank you for contacting us.
If you replace the standard ContextMenu with Telerik's RadContextMenu the problem should be resolved. We will continue investigating the issue.
If you have any other questions please feel free to contact us again.
Greetings,
Konstantina
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.
This issue has also been bothering us for quite some time. Basically we had a tree view inside a Rad Pane and we were not seeing the context menu on the tree view. Please look at this thread: http://www.telerik.com/community/forums/wpf/docking/custom-control-context-menus-an-panes.aspx especially the sample project. The solution there did take care of the problem. In short, here is what you would need to add to your RadPane XAML:
ContextMenuTemplate="{x:Null}"
I just tried it and it worked for me fine. Thought I should share it with you.
Regards
Gaurav
The timing of your post was unreal. 30min before I was going to work on this issue after I'd shelved it for a week. Your resolution works like charm and I'm going into the weekend as happy as I can get.
Thank you with all my heart,
Ogi
You cannot set ContextMenu property to RadContextMenu.
You have to use the telerik:RadContextMenu.ContextMenu attached property in order to set RadContextMenu. Please take a look at our examples:
http://demos.telerik.com/wpf/
Let us know if you need more information.
Kind regards,
Hristo
the Telerik team
I don't want to set ContextMenuTemplate="{x:Null}"; because then I don't get the context menu for that RadPane. I would like to have that context menu, but I'd also like all my textboxes to retain their default context menu without me having to create a template for them. That's extra work that isn't needed since it technically already exists.
Any fixes to this to get the default context menus back?
Unfortunately, this issue is not fixed yet. You can track its progress in our Public Issue Tracking System with Issue ID = 3471.
George
the Telerik team
I have similar problem. I have set ContextMenuTemplate = {x:Null} for my RadPane and RadPane context menu is not getting displayed.
When RadPane is in auto hide state and I right click on my RadGridView which is in RadPane, context menu opens and RadPane gets collapsed and context menu also gets collapsed. How to resolve this problem?
When you set ContextMenuTemplate = {x:Null} for a RadPane, the context menu won't show. This is the expected behavior and the workaround for the problem.
George
the Telerik team
How does anyone suppose to use a docking system when you can't have a normal context menu ?
I have a RadDocumentPane hosting various controls and this bug prevents me to use their context menu !
I'm sorry, but i think this bug should be your top priority, because it's totally unprofessional.
Miky.
We agree with you and this bug is really in our top priority list. We will include a fix for the issue in the official Q1 SP1 release.
I hope this helps. Please do not hesitate to contact us if you require any further information.
George
the Telerik team
It looks like issue 3471 is not scheduled.
Was this actually fixed in SP1?
Update. Per the example, use Telerik's controls:
<
telerik:RadContextMenu.ContextMenu
>
<
telerik:RadContextMenu
>
<
telerik:RadMenuItem
Header
=
"Item 1"
/>
<
telerik:RadMenuItem
Header
=
"Item 2"
/>
<
telerik:RadMenuItem
Header
=
"Item 3"
/>
<
telerik:RadMenuItem
Header
=
"Item 4"
/>
</
telerik:RadContextMenu
>
</
telerik:RadContextMenu.ContextMenu
>
This issue is not fixed yet. Sorry for any inconvenience caused.
George
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
'Telerik.Windows.Controls.RadContextMenu Items.Count:2' is not a valid value for property 'ContextMenu'.
This whole issue with not being able to use a standard ContextMenu in a RadPanelBarItem is becoming rather tiresome. While waiting for a reply, I went to my pane with the tree control and am hitting the same issue - which was introduced above.
The workaround proposed earlier, i.e., adding the attribute ContextMenuTemplate="{x:Null}" allows the use of ContextMenu, but disables the context menu for the RadPane.
Suggestions for implementing the context menu on these items would be greatly appreciated.
Here's my attempt for a TreeView. I've commented out what I believe should have worked and put in only the standard context menu controls and added the attribute to the encapsulating RadPane - and it works.
<
TreeView
HorizontalAlignment
=
"Stretch"
Margin
=
"0,27,0,0"
Name
=
"_tviewConnections"
VerticalAlignment
=
"Stretch"
Width
=
"Auto"
ItemsSource
=
"{Binding ConnectionViewModelList}"
SelectedItemChanged
=
"ScrollIntoView"
>
<
TreeView.Resources
>
<
ContextMenu
x:Key
=
"itemContextMenu"
>
<!--<
telerik:RadContextMenu.ContextMenu
>
<
telerik:RadContextMenu
>
<
telerik:RadMenuItem
Header
=
"Edit"
/>
<
telerik:RadMenuItem
Header
=
"Delete"
/>
</
telerik:RadContextMenu
>
</
telerik:RadContextMenu.ContextMenu
>-->
<
MenuItem
Header
=
"Edit"
/>
<
MenuItem
Header
=
"Delete"
/>
</
ContextMenu
>
</
TreeView.Resources
>
<
TreeView.ItemContainerStyle
>
<!-- this Style binds a TreeViewItem to a TreeviewItemViewModelBase item -->
<
Style
TargetType
=
"{x:Type TreeViewItem}"
>
<
Setter
Property
=
"ContextMenu"
Value
=
"{StaticResource itemContextMenu}"
/>
</
Style
>
</
TreeView.ItemContainerStyle
>
<
TreeView.ItemTemplate
>
<
HierarchicalDataTemplate
ItemsSource
=
"{Binding Children}"
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
Image
Width
=
"16"
Height
=
"16"
Margin
=
"3,0"
Source
=
"{Binding Path=Model.Icon}"
/>
<
TextBlock
Text
=
"{Binding Path=Model.Name}"
/>
</
StackPanel
>
</
HierarchicalDataTemplate
>
</
TreeView.ItemTemplate
>
</
TreeView
>
Here's the general usage that I am attempting:
<
telerik:RadPanelBarItem
Header
=
"All Actions"
Background
=
"#FF4F94CD"
IsDropAllowed
=
"False"
>
<!--Constrain the size of the wrap panel so it can do its thing-->
<
Grid
Width
=
"{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadPanelBar}}, Path=ActualWidth, Converter={StaticResource MathConverter}, ConverterParameter=@VALUE-8;0}"
>
<
ListView
Name
=
"_lviewAllActions"
ItemsSource
=
"{Binding Path=AllActionViewModelList}"
GridViewColumnHeader.Click
=
"OnClick_ListViewHeader"
>
<
ListView.Resources
>
<
telerik:RadContextMenu
x:Key
=
"itemContextMenu"
>
<
telerik:RadMenuItem
Header
=
"Edit"
Click
=
"OnClick_EditMacroAction"
/>
<
telerik:RadMenuItem
Header
=
"Delete"
Click
=
"OnClick_DeleteMacroAction"
/>
</
telerik:RadContextMenu
>
</
ListView.Resources
>
<
ListView.ItemContainerStyle
>
<
Style
TargetType
=
"{x:Type ListViewItem}"
>
<
Setter
Property
=
"ContextMenu"
Value
=
"{StaticResource itemContextMenu}"
/>
</
Style
>
</
ListView.ItemContainerStyle
>
<
ListView.View
>
<
GridView
>
<
GridViewColumn
Header
=
"Type"
DisplayMemberBinding
=
"{Binding Path=ActionType}"
/>
<
GridViewColumn
Header
=
"Name"
DisplayMemberBinding
=
"{Binding Path=Name}"
/>
<
GridViewColumn
Header
=
"Description"
DisplayMemberBinding
=
"{Binding Path=Description}"
/>
</
GridView
>
</
ListView.View
>
</
ListView
>
</
Grid
>
</
telerik:RadPanelBarItem
>
Here's how I arrive at the question:
1) I start with the concept of a dockable tool panel - and try using Telerik's controls:
<
telerik:RadDocking
PreviewShowCompass
=
"RadDocking_PreviewShowCompass"
Close
=
"RadDocking_OnClose"
>
<
telerik:RadDocking.DocumentHost
>
<
telerik:RadSplitContainer
>
<
telerik:RadPaneGroup
Name
=
"_rpanegroupDocuments"
/>
</
telerik:RadSplitContainer
>
</
telerik:RadDocking.DocumentHost
>
<
telerik:RadSplitContainer
>
<
telerik:RadPaneGroup
Name
=
"_rpanegroupTools"
>
<
telerik:RadPane
Header
=
"Connections"
CanUserClose
=
"False"
Name
=
"_rpaneConnections"
ContextMenuTemplate
=
"{x:Null}"
>
<
myToolWindows:ConnectionsPaneView
DataContext
=
"{Binding ConnectionsPaneViewModel}"
/>
</
telerik:RadPane
>
<
telerik:RadPane
Header
=
"Actions"
CanUserClose
=
"False"
Name
=
"_rpaneActions"
ContextMenuTemplate
=
"{x:Null}"
>
<
myToolWindows:ActionsPaneView
DataContext
=
"{Binding ActionsPaneViewModel}"
/>
</
telerik:RadPane
>
</
telerik:RadPaneGroup
>
</
telerik:RadSplitContainer
>
</
telerik:RadDocking
>
2) I host my controls inside a RadPane. Things look fine.
3) I start adding context menus to all the items that require them within the RadPane hosted controls.
4) I rapidly find that the Telerik's docking menu overrides any of my menus. There are a small number of cases that are easily worked around. There are other cases that I am waiting for workaround examples - but don't have high hopes.
5) As a last ditch resort, I use the ContextMenuTemplate="{x:Null}" attribute on the RadPanes to get rid of the Telerik context menus. My thinking was that I could live without the right click context menu and force the users to use that little down-arrow button on the pane headers to change the attributes of the pane.
However, adding the above attribute turns off all access to the RadPane properties offered by the context menu in question.
My context menus now work as expected but without the docking options.
6) Why am I using Telerik's docking controls since I cannot do with them what I need to?
So, will I be alone in abandoning the use of Telerik's docking controls over this issue?
We are really sorry for the troubles you are experiencing, but I tried your scenario and it works pretty good without setting the ContextMenuTemplate to NULL. There was an issue 3 months ago, but it is fixed now and the context menu of the docking control doesn't override the context menus of the controls, placed inside panes. Place, refer to the attached project.
Best wishes,
Miroslav Nedyalkov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
What version of the controls are you using? Last time I looked, this issue was still open in your tracking system.
I have not updated to the most recent release because I had some issues on the first pass. I'll like into updating now and report back.
Edit 1 - Still fails.
I will take your example and embed the tree view and list view controls and send it back shortly.
Edit 2 - Attaching example
I have taken your example and created three RadPanelBarItems: one with your button example, one with my list view problem, and one with my tree view problem. I have rezipped the package and attached it. Your system only allows gif, etc., so I renamed the .zip to .gif to get it uploaded.
At the top of the MainWindow.xaml file, the following block can be found:
<!--Uncomment the following and the list view and tree view context menus work
but the docking functionality is severally limited-->
<
telerik:RadPane
Header
=
"Context Menu Examples"
ContextMenuTemplate
=
"{x:Null}"
>
<!--Uncomment the following and the list view and tree view context menus DO NOT work
but the docking functionality works as expected-->
<!--<telerik:RadPane Header="Context Menu Examples">-->
I've disabled the context menu for the pane. Please start the example and observe that the right-click context menus work for all test items. Comment out the first block above and uncomment the second. Start the example and observe how the context menu works for only your button example.
For the list view and tree view examples, you will see a block of xaml similar to the following:
<
ListView.Resources
>
<
ContextMenu
x:Key
=
"itemContextMenu"
>
<!--Uncomment either this block or the one below-->
<!--<
telerik:RadContextMenu.ContextMenu
>
<
telerik:RadContextMenu
>
<
telerik:RadMenuItem
Header
=
"Menu item 1"
/>
<
telerik:RadMenuItem
Header
=
"Menu item 2"
/>
</
telerik:RadContextMenu
>
</
telerik:RadContextMenu.ContextMenu
>-->
<!--Uncomment either this block or the one above-->
<
MenuItem
Header
=
"Menu item 1"
/>
<
MenuItem
Header
=
"Menu item 2"
/>
</
ContextMenu
>
</
ListView.Resources
>
<
ListView.ItemContainerStyle
>
<
Style
TargetType
=
"{x:Type ListViewItem}"
>
<
Setter
Property
=
"ContextMenu"
Value
=
"{StaticResource itemContextMenu}"
/>
</
Style
>
</
ListView.ItemContainerStyle
>
The resources block is where the context menu is being defined for the items in the list view. There are two subblocks: one with the Telerik context menu items (as was done with the button example) and the other with the standard menu items. Using either one when the RadPane context menu is active will result in the docking menu shown and not the required one. Disabling the docking menu (and the undocking & drag/drop behavior!) results in the anticipated context menus being shown.
While my programming experience is extensive, the years working with xaml can be counted on one finger. There may be an alternate way of getting the required behavior. While I endeavor to follow the mvvm pattern, I am not averse to putting code in the code-behind page when it relates only to the U/I presentation. So, please feel free to suggest a fix from any angle.
BTW, I have just downloaded the WPF 4.0 suite (920) so I'm using the latest code.
Looking forward to your assistance.
CANNOT SUBMIT WITH THE ATTACHED FILE - IT'S DETECTED AS NOT BEING A GIF
I see a hint above that says for entire code sets that a support ticket is the way to go. Will write up the formal request and we can follow it up there.
The PITS issue is not updated, because it states that the ContextMenu should appear only for the Header of the pane, which is not done yet. What we did was to fix the ContextMenu to not override other ContextMenus. The fix was released with the 2011 Q1 SP1 version of RadControls for WPF.
Kind regards,Miroslav Nedyalkov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Using the RadContextMenu has no impact on the TextBox at all.
The following code only gives the desired context menu on the upper text box.
<Window x:Class="DockingContextMenuProblem.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:DockingContextMenuProblem="clr-namespace:DockingContextMenuProblem" Title="MainWindow" Height="350" Width="525">
<Grid>
<telerik:RadDocking>
<telerik:RadSplitContainer>
<telerik:RadPaneGroup>
<telerik:RadPane>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBox Text="Direct">
<TextBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Generate sample data..." />
<MenuItem Header="Read file..." />
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
<DockingContextMenuProblem:UserControl1 Grid.Row="1"/>
</Grid>
</telerik:RadPane>
</telerik:RadPaneGroup>
</telerik:RadSplitContainer>
</telerik:RadDocking>
</Grid>
</Window>
-----
<UserControl x:Class="DockingContextMenuProblem.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TextBox Text="In User Control">
<TextBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Generate sample data..." />
<MenuItem Header="Read file..." />
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
</Grid>
</UserControl>
To disable the default Docking ContextMenu you need to set the ContextMenuService.IsEnabled attached property to false at the root of the content of the RadPane. This will prevent the RadDocking context menu from opening and the ContextMenu you set should be opened instead.
Hope this helps.
Kind regards,
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
the simplest solution is to hook on the ContextMenuOpening event.
there just call:
e.Handled = true;
I am trying to define my own context menu for the RadPane, but neither my template nor setting it to x:Null is having any effect on the RadPane. It always shows up the default context menu. Here is the code where I am trying to set the ContextMenuTemplate to the MyContextMenuTemplate I defined. How can I get my context menu to show up?
<
this:DockableRadPaneView
x:Class
=
"Infrastructure.HierarchyExplorerView"
xmlns:prism
=
"http://www.codeplex.com/prism"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:this
=
"clr-namespace:Infrastructure"
Title
=
"{Binding Path=AdapterTypeString}"
Header
=
"{Binding Path=AdapterTypeString}"
CanDockInDocumentHost
=
"False"
ContextMenuService.IsEnabled
=
"False"
telerik:RadDocking.SerializationTag
=
"{Binding Path=DockableViewName, Mode=OneWay}"
mc:Ignorable
=
"d"
d:DesignHeight
=
"300"
d:DesignWidth
=
"300"
>
<
ContentControl
x:Name
=
"HierarchyExplorerContentControl"
>
<
ContentControl.Resources
>
<
DataTemplate
x:Key
=
"MyContextMenuTemplate"
>
<
telerik:RadContextMenu
InheritDataContext
=
"False"
>
<
telerik:RadMenuItem
IsChecked
=
"{Binding IsFloatingOnly}"
Command
=
"telerik:RadDockingCommands.Floating"
CommandParameter
=
"{Binding}"
CommandTarget
=
"{Binding}"
Header
=
"{Binding Command.Text, RelativeSource={RelativeSource Self}}"
/>
<
telerik:RadMenuItem
IsChecked
=
"{Binding IsDockableOptionChecked}"
Command
=
"telerik:RadDockingCommands.Dockable"
CommandParameter
=
"{Binding}"
CommandTarget
=
"{Binding}"
Header
=
"{Binding Command.Text, RelativeSource={RelativeSource Self}}"
/>
</
telerik:RadContextMenu
>
</
DataTemplate
>
<
Style
TargetType
=
"telerik:RadPane"
>
<
Setter
Property
=
"ContextMenuTemplate"
Value
=
"{StaticResource MyContextMenuTemplate}"
/>
</
Style
>
</
ContentControl.Resources
>
<
Grid
Background
=
"#f0f0f0"
x:Name
=
"HierarchyExplorerGrid"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"233*"
/>
</
Grid.RowDefinitions
>
<
this:HierarchyTreeView
x:Name
=
"HierarchyTreeViewControl"
Grid.Row
=
"0"
TreeViewModel
=
"{Binding Path=TreeViewModel}"
/>
<
Button
Command
=
"{Binding LockCommand}"
Style
=
"{DynamicResource IconButtonStyle}"
Grid.Row
=
"0"
Width
=
"17"
Height
=
"17"
HorizontalAlignment
=
"Right"
VerticalAlignment
=
"Top"
Margin
=
"0,0,17,0"
>
<
uxc:XamlImage
>
<
uxc:XamlImage.Style
>
<
Style
TargetType
=
"{x:Type uxc:XamlImage}"
>
<
Style.Triggers
>
<
DataTrigger
Binding
=
"{Binding IsLocked}"
Value
=
"false"
>
<
Setter
Property
=
"Template"
Value
=
"{DynamicResource Com_Unlock}"
/>
</
DataTrigger
>
<
DataTrigger
Binding
=
"{Binding IsLocked}"
Value
=
"true"
>
<
Setter
Property
=
"Template"
Value
=
"{DynamicResource Com_Lock}"
/>
</
DataTrigger
>
</
Style.Triggers
>
</
Style
>
</
uxc:XamlImage.Style
>
</
uxc:XamlImage
>
</
Button
>
</
Grid
>
</
ContentControl
>
</
this:DockableRadPaneView
>
Thanks,
Jiti
We have tried to reproduce the described behavior in a simple project, but with no luck. We have tried to get as close as we can to your scenario applying the style you have sent to us with the corresponding DataTemplate to a simple Dock, but it seems like the ContextMenu is shown appropriately. Please note that we have tested it with Q1 2013, Q3 2012 and Q3 2012 SP.
I am attaching my test project, so it would be great if you can check it out and see if I am not missing something.
All the best,
Georgi
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Thanks for the response. I am using Q1 2013. I was not able to see anything related to the ContextMenu in the attachment. Could you please check it and let me know.
Thanks,
Jiti
I am sorry for sending you the wrong project.
Attached you can find the project with the Context Menu.
Greetings,
Georgi
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.