RadMenuItem Click - OriginalSource is always null in RC0

3 posts, 0 answers
  1. paul
    paul avatar
    16 posts
    Member since:
    Jul 2008

    Posted 06 Oct 2008 Link to this post

    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. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 06 Oct 2008 Link to this post

    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.
  3. DevCraft banner
  4. paul
    paul avatar
    16 posts
    Member since:
    Jul 2008

    Posted 06 Oct 2008 Link to this post

    Thank you for your response that solved the issue.

    Regards,

    Paul Chapman 
Back to Top