This has happened to me once before: I added a drop shadow to a border control, and all of a sudden my context menus didn't pop up; remove the drop shadow and they're back.....
Any insight would be greatly appreciated.
17 Answers, 1 is accepted
Please, check first if your Silverlight plugin is in windowless mode - it is required for the right-click support of RadContextMenu. Other thing that might break it is the browser zoom:
When the page is zoomed-in the right-click does not correctly report the mouse coordinates and the context menu does not open.
If the suggestions above do not help, please, open a new support ticket and send us a simple application that demonstrates the problem. We will respond with a solution as soon as possible.
Best wishes,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
when will this problem be solved? I just tried it with the latest Silverlight RadControls release, but still when zooming the browser the contextmenu get's the wrong position.
br,
Markus
Could you please, provide more information about your scenario? Browser, Silverlight runtime version, RadControls for Silverlight version, etc. If possible please, open a new support ticket and send us a simple application + steps to reproduce the problem and we will respond with a suggestion or bug fix as soon as possible.
All the best,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
thank you for fast response!
Silverlight: 2.0
RadControls: 2009.1.0312.1020 (but is the same with RadControls_for_Silverlight_2009_2_0812).
Browser: IE 8 (on Windows 7)
Constructor of page:
...
// Adds support for opening the context menu by right mouse button click
HtmlPage.Document.AttachEvent("oncontextmenu", this.OnContextMenu);
...
Handler of contextmenu:
///
<summary>
/// Occers, when the user clicks the right mouse button.
/// </summary>
/// <param name="sender">The sender of the event.</param>
/// <param name="e">EventArgs of the event.</param>
private void OnContextMenu(object sender, HtmlEventArgs e)
{
var elements = VisualTreeHelper.FindElementsInHostCoordinates(new Point(e.OffsetX, e.OffsetY), this).ToList();
this.LoadContextMenu(elements); // here menuitems are displayed/hidden accoring to the element the menu is called for
e.PreventDefault();
}
When executing this code with zoom 100% evereything works fine, the contextmenu opens for the correct elements. When zoomlevel is different (e.g. 125%) the contextmenu opens over completely wrong elements.
br,
Markus
In version 2, Silverlight does not report correctly the mouse coordinates when the browser zoom is on. I suppose this is the reason for the problem. On the other hand, I see that you are using custom code to open the context menu - why don't you let the control to determine when and where to display itself?
Sincerely yours,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
in our custom code the opening position is not modified. We need custom code here as some context menu items are displayed depending on the element the context menu is opend for (i.e. the element, the right mouse button is clicked on).
Do you know another way to determine the elements the context menu is opened on?
br,
Markus
I just checked our online samples, it seems that there is still a problem - when a popup is opened, the browser zoom is reset, which results in wrong coordinates. I found and fixed the root of the problem. The upcoming internal build today will contain the fix.
All the best,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
could you fix the zoom problem? If yes, how can I get a fixed version?
br,
Markus
We failed to release an internal build the last friday, I apologize for that. This friday's build will be released on time. If you need the fix earlier, please, open a new support ticket and we will attach the assemblies there.
Sincerely yours,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
just to check before I start downloading and testing, could you manage including this fix in the newest internal build?
br,
Markus
You can download the latest internal build and give it a try. The files are located under your account's Downloads section.
Let us know how this goes.
Sincerely yours,
Kaloyan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I tried, but without success :-(
br,
Markus
I created a simple application that uses the internal RadContextMenu mechanism for opening and getting the element that is below, that appears to be working properly when the browser is zoomed. I didn't removed the assemblies (Trial version because this is a forum) in order to allow you to test the application as it is on my side.
Kind regards,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Am also getting the same problem that my context menu is not displaying whenever i used rightclick of an item.
My Telerik version of dll is :2009.2.701.1020
and my silverlight version is 3 and rad is q2
Instead am getting silverlight context menu as "Silverlight".
Would that be a problem.
Thanks
<UserControl x:Class="ProdShowcase.test1" |
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" |
xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
Width="647" Height="285"> |
<StackPanel x:Name="LayoutRoot"> |
<telerikNavigation:RadContextMenu.ContextMenu> |
<telerikNavigation:RadContextMenu |
Opened="RadContextMenu_Opened_1"> |
</telerikNavigation:RadContextMenu> |
</telerikNavigation:RadContextMenu.ContextMenu> |
<Grid Width="100" Height="100" Background="Red" HorizontalAlignment="Left" /> |
<Grid Width="100" Height="100" Background="Blue" HorizontalAlignment="Left" /> |
<TextBlock x:Name="text" /> |
<Grid Width="100" Height="100" Background="Red" HorizontalAlignment="Left" /> |
<Grid Width="100" Height="100" Background="Blue" HorizontalAlignment="Left" /> |
</StackPanel> |
</UserControl> |
My cs code file is this
using System; |
using System.Windows; |
using System.Windows.Controls; |
using Telerik.Windows.Controls; |
using Telerik.Windows; |
using System.Windows.Media.Imaging; |
using System.Windows.Media; |
using System.Windows.Shapes; |
namespace ProdShowcase |
{ |
public partial class test1 : UserControl |
{ |
public test1() |
{ |
InitializeComponent(); |
//rectangle.SetValue(RadContextMenu.ContextMenuProperty, contextMenu); |
} |
private void RadContextMenu_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e) |
{ |
var rect = (sender as RadContextMenu).GetClickedElement<Grid>(); |
if (rect != null) |
{ |
this.text.Text = (e.OriginalSource as RadMenuItem).Header.ToString(); |
} |
} |
private void RadContextMenu_Opened(object sender, RoutedEventArgs e) |
{ |
var contextMenu = sender as RadContextMenu; |
var rect = contextMenu.GetClickedElement<Grid>(); |
if (rect != null) |
{ |
contextMenu.Items.Clear(); |
if ((rect.Background as SolidColorBrush).Color.Equals(Colors.Red)) |
{ |
this.LoadRedItems(contextMenu); |
} |
else |
{ |
this.LoadBlueItems(contextMenu); |
} |
} |
else |
{ |
contextMenu.IsOpen = false; |
this.text.Text = "Please, click on a rectangle"; |
} |
} |
private void LoadRedItems(RadContextMenu contextMenu) |
{ |
contextMenu.Items.Add(new RadMenuItem() { Header = "Red 1" }); |
contextMenu.Items.Add(new RadMenuItem() { Header = "Red 2" }); |
contextMenu.Items.Add(new RadMenuItem() { Header = "Red 3" }); |
} |
private void LoadBlueItems(RadContextMenu contextMenu) |
{ |
contextMenu.Items.Add(new RadMenuItem() { Header = "Blue 1" }); |
contextMenu.Items.Add(new RadMenuItem() { Header = "Blue 2" }); |
contextMenu.Items.Add(new RadMenuItem() { Header = "Blue 3" }); |
} |
private void RadContextMenu_Opened_1(object sender, RoutedEventArgs e) |
{ |
} |
} |
} |
The RadContextMenu is working only if you set the WindowsLess mode to true in your Silverlight definition of your startup html page.
<
object
data
=
"data:application/x-silverlight-2,"
id
=
"Xaml1"
type
=
"application/x-silverlight-2"
width
=
"100%"
height
=
"100%"
>
<
param
name
=
"source"
value
=
"Examples/Examples.CS.xap"
/>
<
param
name
=
"onerror"
value
=
"onSilverlightError"
/>
<
param
name
=
"background"
value
=
"#084E85"
/>
<
param
name
=
"Windowless"
value
=
"true"
/>
<
param
name
=
"minRuntimeVersion"
value
=
"3.0.40624.0"
/>
</
object
>
Regards,
Kaloyan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Our code works fine for me in either IE or Firefox, so it is difficult for me to troubleshoot. For the most part we use code very similar to that found in this article, Reusing and customizing a single ContextMenu on a TreeView with RadControls for Silverlight.
Interestingly enough, I do experience the same or at least a similar context menu problem using the source code, ContextMenuInTreeView2.zip, provided in the article when using Firefox; it works fine with IE. I found that in order to make it work for me in Firefox, I had to use a general tranform by changing this code:
private T FindElementAt<T>(Point coordinates) where T : UIElement
{
return (T)VisualTreeHelper.FindElementsInHostCoordinates(coordinates, this)
.FirstOrDefault((element) => element is T);
}
to this:
private
T FindElementAt<T>(Point coordinates) where T : UIElement
{
GeneralTransform generalTransform = TreeView.TransformToVisual(Application.Current.RootVisual);
Point childToParentCoordinates = generalTransform.Transform(coordinates);
T firstOrDefault = (T)
VisualTreeHelper.FindElementsInHostCoordinates(childToParentCoordinates, this).FirstOrDefault(
(element) => element
is T);
return firstOrDefault;
}
With the original code, the "New Child" would be added to the wrong parent. It would add it to the parent above. Here are the steps that I performed:
1. Expand "Item 3"
2. Right mouse click on "Item 3.3"
3. Select "New Child" from the context menu
The "New Child" node gets added to "Item 3.2"; not "Item 3.3" as expected.
Furthermore, I noticed that if I bring up the context menu by clicking on the bottom portion of the "Item 3.3" tree node, the "New Child" node gets added to "Item 3.3". However, if I bring up the context menu by clicking on the middle or top portion of the "Item 3.3" tree node, the child node is added to the wrong parent.
So, I thought great, I will add the general transform code that worked in this example code to our code, but unfortunately it still doesn't seem to overcome the problem :(
Is this a known problem or is there anything else that you can suggest that I try?
Thanks,
Kevin
We are using Telerik DLL version: 2009.3.1314.1030
Kaloyan
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.