Problem with RadContextMenu.GetClickedElement while using with RadTileViewItem

15 posts, 0 answers
  1. SivaPrasad Bevara
    SivaPrasad Bevara avatar
    73 posts
    Member since:
    Oct 2012

    Posted 29 Oct 2010 Link to this post


    Hi,

    I am using the RadContextMenu to show the "Close" option, when I right click on the RadContextMenuItem. I am facing the following problem when I use the context menu to close the RadTileViewItem for the second time.

    Menu.GetClickedElement<RadTileViewItem>()' threw an exception of type 'System.ArgumentException' Telerik.Windows.Controls.RadTileViewItem {System.ArgumentException}

    Following is the code which I am using for this.

    <telerikNavigation:RadContextMenu.ContextMenu> <telerikNavigation:RadContextMenu x:Name="RadTileViewContextMenu" Height="40" Width="120" ItemClick="ContextMenu_ItemClick"> <telerikNavigation:RadMenuItem Header="Close"></telerikNavigation:RadMenuItem>

     

    </telerikNavigation:RadContextMenu>
    </telerikNavigation:RadContextMenu.ContextMenu>

     

     

     

     


    private

     

     

    void ContextMenu_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)

     

    {

     

     

    RadContextMenu Menu = sender as RadContextMenu;

     

    if (Menu.GetClickedElement<RadTileViewItem>() != null)
    {

     

    RadTileViewItem ClickedItem = Menu.GetClickedElement<RadTileViewItem>() as RadTileViewItem;

     

     

    MDIMainTile.Items.Remove(ClickedItem);

    }

    }

    }

     

     


    Following is the Scenario where I am getting the error.

    Lets think we have 3 Tileviews, out of one is Maximized and other 2 are minimized. Right click on the Maximized Item and choose the close option from contextMenu. It will close properly and another Item will be Maximized automatically. Now again Right click on the Item which is maximized and select the close option. In this case I am facing the above mentioned error for Menu.GetClickedElement<RadTileViewItem>() .

    Please suugest.

    Regards,
    SivaPrasad.B
  2. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 01 Nov 2010 Link to this post

    Hi SivaPrasad Bevara,

     I  wasn't able to reproduce your problem, so could you please examine the attached project and if you still have that issue please send us some more code? 

    All the best,
    Zarko
    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
  3. DevCraft banner
  4. Shawn Burke
    Shawn Burke avatar
    13 posts
    Member since:
    Sep 2009

    Posted 28 Dec 2010 Link to this post

    Hello there,

    Could you please add a workaround for invisible controls to the beginning of the ApplicationHelper.TransformToScreenRoot().
    Something like this:

    #if SILVERLIGHT

     if (!RootVisual.IsAncestorOf(target)) // Invisible
     {
        return ...  
     }
            
     var generalTransform = target.TransformToVisual(null);
     ....

    Thanks

  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 03 Jan 2011 Link to this post

    Hi Shawn Burke,

    The ApplicationHelper class is an internal class and as such is created for internal use only. Therefore we're not planning to modify it.

    Best wishes,
    Tina Stancheva
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  6. Shawn Burke
    Shawn Burke avatar
    13 posts
    Member since:
    Sep 2009

    Posted 03 Jan 2011 Link to this post

    Hi Tina,

    The implementation of this method assumes that the 'target' is always in the visual tree. This is wrong assumption (if an element is not in the visual tree, you cannot call TransformToVisual on it)  and very likely source of the error mentioned in the original post.

    Regards


  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 05 Jan 2011 Link to this post

    Hello SivaPrasad Bevara,

    The TransformToScreenRoot() method cannot transform to ScreenRoot target that isn't a part of the visual tree. Also, we couldn't reproduce the issue originally raised in this thread on our side and if you can reproduce it, we would highly appreciate it if you can send us a sample project illustrating a scenario where the issue is reproduced and where the target of the TransformToScreenRoot() method isn't a part of the visual tree. Also, can you elaborate on what you expect the TransformToScreenRoot() method to return for such controls?

    All the best,
    Tina Stancheva
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  8. Shawn Burke
    Shawn Burke avatar
    13 posts
    Member since:
    Sep 2009

    Posted 06 Jan 2011 Link to this post

    Hi Tina,

    When the RadContextMenu.GetClickedElement<>() method is called  the following exception is thrown:

    System.ArgumentException: Value does not fall within the expected range.

    Here is the stack trace: 

    at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
    at MS.Internal.XcpImports.MethodPack(IntPtr
    objectPtr, String methodName, Object[] rawData)
    at 
    MS.Internal.XcpImports.UIElement_TransformToVisual(UIElement element, UIElement visual)
    at System.Windows.UIElement.TransformToVisual(UIElement
    visual)
    at 
    Telerik.Windows.Controls.ApplicationHelper.TransformToScreenRoot(UIElement target)
    at 
    Telerik.Windows.Controls.VisualTreeHelperExtensions.GetElementsInHostCoordinates[T](UIElement subtree, Point position)
    at 
    Telerik.Windows.Controls.VisualTreeHelperExtensions.GetElementsInScreenCoordinates[T](Point mousePosition, FrameworkElement rootVisual)
    at 
    Telerik.Windows.Controls.VisualTreeHelperExtensions.GetElementsInScreenCoordinates[T](FrameworkElement relativeTo, Point mousePosition)
    at 
    Telerik.Windows.Controls.RadContextMenu.GetClickedElement[T]()

    It happens when the control, to which the context menu is linked, is not in the visual tree. There are workarounds for this, but frankly the simplest way is to fix it in the ApplicationHelper.TransformToScreenRoot() method.

    Regards

  9. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 12 Jan 2011 Link to this post

    Hi Shown,

    First of all accept my apology for the delayed response. We will definitely look into this and I will keep you posted.

    Greetings,
    Tina Stancheva
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  10. Matthew Cartwright
    Matthew Cartwright avatar
    31 posts
    Member since:
    Oct 2005

    Posted 21 Jan 2011 Link to this post

    We are experiencing the same issue intermittently. Any updates on a fix for this?
  11. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 21 Jan 2011 Link to this post

    Hi guys,

    Can you please test your projects against the Q3 SP1 official release (version 2010.3.1314) and let us know if you still experience any issues?

    Thank you in advance.

    Greetings,
    Tina Stancheva
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  12. Matthew Cartwright
    Matthew Cartwright avatar
    31 posts
    Member since:
    Oct 2005

    Posted 21 Jan 2011 Link to this post

    HI. We are using the 2010.3.1110 version.

    I am reluctant to role out a new version on the basis that it _might_ fix our problem. We are not able to consistently reproduce this, so would not be able to determine if the new version has made a difference or not.

    Are you able to point me to something in the 2010.3.1314 release note that would suggest this issue might be fixed, and give us more confidence in rollling out this update?

    Thanks,
    Matt
  13. Shawn Burke
    Shawn Burke avatar
    13 posts
    Member since:
    Sep 2009

    Posted 21 Jan 2011 Link to this post

    Tina,

    I installed the sp1 and it fixed the issue for me.

    Thank you.
  14. Matthew Cartwright
    Matthew Cartwright avatar
    31 posts
    Member since:
    Oct 2005

    Posted 24 Jan 2011 Link to this post

    Hi Shawn,

    Are you able to repeatably reproduce this issue? In our scenario we are only getting this problem in test, and very very rarely ( about 5 times in 4 days).

    Do you have a repro solution that you are able to share that might help us narrow down our use-case?

    Thanks,
  15. Shawn Burke
    Shawn Burke avatar
    13 posts
    Member since:
    Sep 2009

    Posted 24 Jan 2011 Link to this post

    Matthew,

    The SP1 fixed the issue I had with RadContextMenu.GetClickedElement (see my previous post).

    Regards
  16. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 26 Jan 2011 Link to this post

    Hello Matthew,

    With the Q3 SP1 2010 release we modified the  ApplicationHelper class not to throw the exception that Shawn reported. And although I understand you uncertainty about upgrading your RadControls version, I am afraid that there isn't much that we can do to assist you unless we manage to reproduce your issue on our side.

    So if you can isolate the issue and reproduce it in a specific scenario, we will be able to further investigate it and let you know if this fix will work for you as well.

    All the best,
    Tina Stancheva
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Back to Top
DevCraft banner