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

RadContextMenu.GetClickedElement(

17 Answers 322 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Priya Iyer
Top achievements
Rank 1
Priya Iyer asked on 27 Jul 2010, 09:24 PM

 

 

private void RadContextMenuOpportunities_Opened(object sender, RoutedEventArgs e)

 

{

 

 

 

RadTreeViewItem item = radContextMenuOpportunities.GetClickedElement<RadTreeViewItem>();

 

 

 

 

if(item!=null)

 

{

CreatePageOppMainItemTab(item);

}

}


I have ContextMenu within the tree. When I right click and open a menu item I'm not getting proper item. But I'm getting another RadTreeViewItem in same tree.

Is this the way to get clicked TreeViewItem?

RadTreeViewItem item = radContextMenuOpportunities.GetClickedElement<RadTreeViewItem>();


Thanks!

Priyastha

 

17 Answers, 1 is accepted

Sort by
0
Viktor Tsvetkov
Telerik team
answered on 28 Jul 2010, 09:33 AM
Hi Priya Iyer,

This is the way to get the clicked item so could you please send us your sample project so I will be able to investigate your problem.

On a side note, I'd like to inform you that we've just released an online tool that allows you to reduce the size of your Silverlight applications. For more information, please visit http://blogs.telerik.com/blogs/posts/10-06-10/telerik_assembly_minifier.aspx

Greetings,
Viktor Tsvetkov
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
Wiktor
Top achievements
Rank 1
answered on 23 Nov 2010, 05:46 AM
Hi,
I have the same problem with RadGridView. In maybe 5-10% of the cases when I right-click on a row, a wrong row is returned by RadContextMenu.GetClickedElement<GridViewRow>(). To make it happen I just keep clicking on different rows, and eventually a random row is returned by GetClickedElement().

This is the code I have:
 
private void GridViewContextMenu_Opened(object sender, RoutedEventArgs e) 
{
  var row = ((RadContextMenu)sender).GetClickedElement<GridViewRow>(); 
  RadContextMenu contextMenu = sender as RadContextMenu;
  if (row == null)  
  {
     contextMenu.IsOpen = false
  }
  else 
  {
     row.IsSelected = true
  }

 

 

 

<telerik:RadGridView
  <telerik:RadContextMenu.ContextMenu>  
    <telerik:RadContextMenu Opened="GridViewContextMenu_Opened">
      <telerik:RadMenuItem Header="Edit" Click="EditMenuItem_Click"/> 
    </telerik:RadContextMenu>   
  </telerik:RadContextMenu.ContextMenu>
...
</telerik:RadGridView

 

 

 

Best regards,
Wiktor

0
Viktor Tsvetkov
Telerik team
answered on 23 Nov 2010, 10:07 AM
Hello Wiktor,

I was not able to reproduce your issue. Could you please examine the attached sample project and modify it if I am missing something and could you please make a screencast of the undesired behavior?

Best wishes,
Viktor Tsvetkov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Wiktor
Top achievements
Rank 1
answered on 23 Nov 2010, 04:59 PM

Hi Viktor,
I can reproduce the result without making any changes to your project. However, the behavior is visible only when clicking on cells with text, and when I change IE zoom to 125%.

 

http://www.screencast.com/t/dwF14FCk

Best regards,
Wiktor
0
Viktor Tsvetkov
Telerik team
answered on 26 Nov 2010, 09:45 AM
Hello Wiktor,

I can confrim that this is a bug, so I have logged it in our PITS under the name "ContextMenu: GetClickedElement does not return the correct element" and it will be ready for tracking and voting tomorrow the latest. I have updated your Telerik account.

Kind regards,
Viktor Tsvetkov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Paul Brun
Top achievements
Rank 2
answered on 29 Nov 2010, 09:36 PM
I can observe this issue when using the RadContextMenu within a TreeView, however, we are not setting the Browser Zoom level. Simply using the default.

It also appears after right-clicking the item to open the context menu, left clicking on another item doesn't appear change the selected item and if we were to apply an IsExpanded property on the element we thought we left-clicked, it would expand the previously selected right-clicked item.

Thoughts?

paul
0
Viktor Tsvetkov
Telerik team
answered on 30 Nov 2010, 09:34 AM
Hi Paul Brun,

Could you please send us a sample project that reproduces the problem?

Sincerely yours,
Viktor Tsvetkov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Giancarlo Aguilera
Top achievements
Rank 1
answered on 13 Apr 2011, 01:43 AM
Hello Victor from Telerik,

I was wondering if this problem has been resolved. We are using version 2010.3.1314.1040. I ask because we are experiencing this problem. Thank you
0
Valeri Hristov
Telerik team
answered on 15 Apr 2011, 03:27 PM
Hi Giancarlo,

We recently made a few changes in this functionality, that might be related to this problem. I would recommend trying the upcoming service pack early next week and checking if the problem persists. I am not 100% sure, but the update might have been included in the internal build from this week (version 2011.1.411), so it is also worth checking.

All the best,
Valeri Hristov
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
Peran
Top achievements
Rank 1
answered on 27 Jun 2011, 08:15 PM
Hi Valeri,

I have updated to version 2011.1.627.1040 and I still have an issue with a context menu on a RadGridView.

When the application is running with browser zoom (IE9 115%) GetClickedElement returns the incorrect row.

I cannot find an issue in PITS for this.


Regards

Peran
0
Hristo
Telerik team
answered on 28 Jun 2011, 08:44 AM
Hello Peran,

GetClickedElement internally use VisualTreeHelper.FindElementsInHostCoordinates method.
Unfortunately FindElementsInHostCoordinates have a bug when browser is zoomed and does not return the real element (but the element which is over if the browser is at 100%).
We have reported it to Microsoft but there is still no fix.
Sorry for the caused inconvenience.

Kind regards,
Hristo
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
Peran
Top achievements
Rank 1
answered on 10 Jul 2011, 07:11 PM
Hi Hristo,

Is there a link to the issue at Microsoft? If there is I would like to vote for it to be fixed.

As a work around, do you know how I could:

1) Check the browser zoom level at application start up.
2) Monitor for browser zoom changes whilst the application is running.
3) Get my application to automatically change the browser zoom back to 100%.


Thanks

Peran

0
Peran
Top achievements
Rank 1
answered on 19 Jul 2011, 06:55 PM
The work around is to add this to Application_Startup, preventing the browser zoom level impacting the silverlight app:

Host.Settings.EnableAutoZoom = false;
0
John Gartee
Top achievements
Rank 1
answered on 03 Nov 2011, 02:00 AM
As a behavioral update to this bug, I have noticed the following:

Using IE 8, no zoom, default settings.

If you right-click to invoke the context menu anyware above the middle of the header of the treenode, I seem to get the correct node returned on my call to GetClickedElement().  If I right-click on the bottom half of the tree node headter, the call returns the next node in the tree (the one below the desired node).

I have not tested this for other behaviors, but it appears to point to there simply being a bug in the code that calculates the element at the right-click mouse position...perhaps using the center of the element as the determination of the target?  I cannot say if this is isolated to VisualTreeHelper.FindElementsInHostCoordinates (by your comment, I assume this is a Microsoft routine) or just in the telerik code.  Are they sure they are sending in the appropriate Point?

Just a thought...


Just my two cents. 
0
Hristo
Telerik team
answered on 03 Nov 2011, 08:38 AM
Hi John,

We were unable to reproduce this issue. I've tested your scenario using Q2 2011 SP1.
Could you please send us sample project so that we can reproduce it?

Greetings,
Hristo
the Telerik team

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

0
Fredy
Top achievements
Rank 1
answered on 30 Jan 2014, 09:01 PM
Hi, I have this problem in radgridview
1. select a cell
2. Do right Click in any other cell, return the selected cell:

(Attach image)

return m_gridContextMenu.GetClickedElement<GridViewRow>();
0
Yana
Telerik team
answered on 05 Feb 2014, 09:01 AM
Hello Fredy,

I did not manage to reproduce the displayed in the screenshot issue with the latest Q3 2013 SP2 release of UI for Silverlight.

I would suggest that you take a look at the following help topic:
http://www.telerik.com/help/silverlight/radcontextmenu-how-to-use-radcontextmenu-with-radgridview.html
which explains in details how you can use RadGridView with RadContextMenu and if you still experience the issue, please send us a sample project where it can be replicated, so we to be able to research it further.

Regards,
Yana
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
General Discussions
Asked by
Priya Iyer
Top achievements
Rank 1
Answers by
Viktor Tsvetkov
Telerik team
Wiktor
Top achievements
Rank 1
Paul Brun
Top achievements
Rank 2
Giancarlo Aguilera
Top achievements
Rank 1
Valeri Hristov
Telerik team
Peran
Top achievements
Rank 1
Hristo
Telerik team
John Gartee
Top achievements
Rank 1
Fredy
Top achievements
Rank 1
Yana
Telerik team
Share this question
or