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

Problem with RadContextMenu.GetClickedElement while using with RadTileViewItem

14 Answers 212 Views
TileView
This is a migrated thread and some comments may be shown as answers.
SivaPrasad Bevara
Top achievements
Rank 1
SivaPrasad Bevara asked on 29 Oct 2010, 02:27 PM

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

14 Answers, 1 is accepted

Sort by
0
Zarko
Telerik team
answered on 01 Nov 2010, 04:48 PM
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
0
Shawn Burke
Top achievements
Rank 1
answered on 28 Dec 2010, 10:04 PM

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

0
Tina Stancheva
Telerik team
answered on 03 Jan 2011, 01:00 PM
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
0
Shawn Burke
Top achievements
Rank 1
answered on 03 Jan 2011, 05:50 PM
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


0
Tina Stancheva
Telerik team
answered on 05 Jan 2011, 04:58 PM
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
0
Shawn Burke
Top achievements
Rank 1
answered on 06 Jan 2011, 05:41 PM
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

0
Tina Stancheva
Telerik team
answered on 12 Jan 2011, 10:21 AM
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>>
0
Matthew Cartwright
Top achievements
Rank 1
answered on 21 Jan 2011, 01:52 PM
We are experiencing the same issue intermittently. Any updates on a fix for this?
0
Tina Stancheva
Telerik team
answered on 21 Jan 2011, 03:18 PM
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>>
0
Matthew Cartwright
Top achievements
Rank 1
answered on 21 Jan 2011, 04:13 PM
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
0
Shawn Burke
Top achievements
Rank 1
answered on 21 Jan 2011, 07:14 PM
Tina,

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

Thank you.
0
Matthew Cartwright
Top achievements
Rank 1
answered on 24 Jan 2011, 10:25 AM
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,
0
Shawn Burke
Top achievements
Rank 1
answered on 24 Jan 2011, 06:36 PM
Matthew,

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

Regards
0
Tina Stancheva
Telerik team
answered on 26 Jan 2011, 02:58 PM
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>>
Tags
TileView
Asked by
SivaPrasad Bevara
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Shawn Burke
Top achievements
Rank 1
Tina Stancheva
Telerik team
Matthew Cartwright
Top achievements
Rank 1
Share this question
or