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

Two bugs

8 Answers 69 Views
Menu
This is a migrated thread and some comments may be shown as answers.
hwsoderlund
Top achievements
Rank 1
hwsoderlund asked on 26 Nov 2008, 03:07 PM
I think I've found two bugs. They're both illustrated with screenshots in the powerpoint file (link below). Let me know if you need more info. /Henrik

http://cid-cc43a90a79374ebd.skydrive.live.com/self.aspx/Public/RadMenu|_Bugs.zip


8 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 26 Nov 2008, 04:57 PM
Hi Henrik,

I've created RadWindow and added RadMenu inside (from the link) but I'm not sure if this is the correct case.
I did notice one bug (due to the change that UserControl no longer clip its content) and fixed it. But I was unable to reproduce the bugs that you reported.
Could you send me a sample project so I get investigate it further?

Thanks and sorry for the troubles.


Best wishes,
Hristo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
hwsoderlund
Top achievements
Rank 1
answered on 26 Nov 2008, 07:03 PM
Here's a sample project. Just click the arrow in the top right corner to trigger the bug.

http://cid-cc43a90a79374ebd.skydrive.live.com/self.aspx/Public/RadMenuBug|_SampleProject.zip
0
Hristo
Telerik team
answered on 27 Nov 2008, 07:36 AM
Hello Henrik,

Silverlight 2 is a great platform but it has some bugs. One of them is the bug where you are not allowed to call TransformToVisual method from an element that is not in the main visual tree. Now this is a real problem especially for RadWindow because the window is not in the main visual tree. RadWindow is displayed in Popup control and the visual tree of the popup is not connected with the main visual tree (the main visual tree is the tree from Application.Current.RootVisual). So in order to be able to call TransformToVisual from RadWindow and its content we need to attach the window popup to the main visual tree. But to be able to do it we need Application.Current.RootVisual to be created.
The general recommendation is to open RadWindow after the Page Loaded event has been fired.

So in your case if you move window opening in loaded event - everything should be working fine.
I am sorry for the inconvenience but until Microsoft fix this bug we cannot offer better solution.


Best wishes,
Hristo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
hwsoderlund
Top achievements
Rank 1
answered on 27 Nov 2008, 10:12 AM
This was confusing at first, until I realised that the bug in the sample project is completely unrelated to my original bugs. In fact, in my real application I'm not opening the windows in the constructor, I'm doing it in Button.OnClick. Here's a new sample project that demonstrates the second of the bugs in the powerpoint file. To trigger the bug, do the following:
  1. Click the button to open the window
  2. Click the top menu button to open the menu
  3. Close the window
  4. Repeat steps 1-3 and the menu will be empty.
  5. Repeat steps 1-3 again and the app will crash.

http://cid-cc43a90a79374ebd.skydrive.live.com/self.aspx/Public/RadMenuBugs|_SampleProject02.zip
0
Accepted
Hristo
Telerik team
answered on 27 Nov 2008, 05:46 PM
Hi Henrik,

In the sample you provided I saw that there was an error at step 4.
The error stated that an item with the same x:Name already existed.

It appears that you cannot set x:Name attribute on ItemsControl that show its items in the Popup control (and the same ItemsControl is in popup). For example, if you modify your project to use ComboBox instead of RadMenu and Popup control instead of RadWindow (and one more button to close the popup), you will experience the same behavior. I tried to find workarounds but with no success.

So the only solution I can suggest at the moment is that you remove the x:Name attributes.


Kind regards,
Hristo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
hwsoderlund
Top achievements
Rank 1
answered on 27 Nov 2008, 06:23 PM
Ah, I see. I guess I'll just hook up the event handlers in xaml instead and get rid of the names. Thanks.

Regarding the other bug (where the menu makes it first appearance half way outside the browser window) I've so far been unable to reproduce it outside my "real" application (which I can't send you due to a number of reasons).  I'm guessing it has something to do with the container that the window resides in. I'll investigate it further when I get the time, but as long as we're rid of the crashes it isn't too big a deal.

Best regards, /Henrik
0
Hristo
Telerik team
answered on 28 Nov 2008, 07:41 AM
Hi Henrik,

May I suggest using the routed events to catch the menuitem click event. Here is a sample code:

using System.Windows;  
using System.Windows.Controls;  
using Telerik.Windows;  
using Telerik.Windows.Controls;  
 
namespace SilverlightDockingDemo  
{  
    public partial class Page5 : UserControl  
    {  
        public Page5()  
        {  
            InitializeComponent();  
            this.AddHandler(RadMenuItem.ClickEvent, new RoutedEventHandler(OnMenuItemClick));  
        }  
 
        private void OnMenuItemClick(object sender, RoutedEventArgs args)  
        {  
            RadRoutedEventArgs e = args as RadRoutedEventArgs;  
            RadMenuItem menuItem = e.OriginalSource as RadMenuItem;  
            // Do something base on menuItem.Header property  
        }  
    }  

This way you don't need the x:Name attribute and there is no need to attach handler to all RadMenuItems Click event separately. The only thing is to attach handler to element that is visual parent of all menuItems (for example RadMenu, RadContextMenu or Page5 in this code).

The cast from RoutedEventArgs to RadRoutedEventArgs is needed because the OriginalSource property is readonly. We will probably change the delegate type for the next major release.

If you need more information, I'll be glad to help.


Sincerely yours,
Hristo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
hwsoderlund
Top achievements
Rank 1
answered on 03 Dec 2008, 08:12 AM
You're right, that's much better.
Tags
Menu
Asked by
hwsoderlund
Top achievements
Rank 1
Answers by
Hristo
Telerik team
hwsoderlund
Top achievements
Rank 1
Share this question
or