This is a migrated thread and some comments may be shown as answers.
RadMenuItem Click - OriginalSource is always null in RC0
2 Answers 61 Views
This is a migrated thread and some comments may be shown as answers.
paul
Top achievements
Rank 1
paul asked on 06 Oct 2008, 07:53 AM
In RC0, code that was previously working now fails.

I have a RadMenu with RadMenuItems bound to a Dictionary<int,string> displaying the dictionary 'Value' in the header.

In the click event, we get the corresponding 'Key' from the selected item.

In RC0, the following selectedItem is always null.

private void nodesItem_Click(object sender, RoutedEventArgs e)  
        {  
            var selectedItem = e.OriginalSource as RadMenuItem;  
 
            if (selectedItem != null)  
            {  
                var data = (KeyValuePair<intstring>)selectedItem.DataContext;  
 
                var nodeSummary = new NodeSummary(data.Key);  
 
                //do stuff...
                
                
            }  
        } 

Has this changed between SLB2 and RC0?

Kind Regards,

Paul Chapman

2 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 06 Oct 2008, 01:25 PM
Hi paul,

RoutedEventArgs changed between beta 2 and RC0. Now it have OrignalSource readonly property (in beta 2 it was read/write Source property).
So now the only way to get original sender is to cast the RoutedEventArgs to RadRoutedEventArgs.
private void nodesItem_Click(object sender, RoutedEventArgs e)     
{     
   RadRoutedEventArgs args = e as RadRoutedEventArgs;  
   var selectedItem = args.OriginalSource as RadMenuItem;     
   if (selectedItem != null)     
   {     
      var data = (KeyValuePair<intstring>)selectedItem.DataContext;     
      var nodeSummary = new NodeSummary(data.Key);     
      //do stuff...   
   }     


Then Source and OriginalSource properties will be correctly populated.
We will update the Delegate so this problem will be resolved in the future release.

Sorry for the inconvenience.
If you have other question do not hesitate to contact us.

Regards,
Hristo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
paul
Top achievements
Rank 1
answered on 06 Oct 2008, 01:33 PM
Thank you for your response that solved the issue.

Regards,

Paul Chapman 
Tags
Menu
Asked by
paul
Top achievements
Rank 1
Answers by
Hristo
Telerik team
paul
Top achievements
Rank 1
Share this question
or