Check/uncheck bug in context menu

4 posts, 1 answers
  1. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 26 Mar 2009 Link to this post

    I'm trying to make it so that only one menu item can be checked at any one time. Sort of like radio buttons. But when I uncheck menu items programmatically the change doesn't show until I mouse over the items. Below is some sample code that demonstrates the bug. To recreate:
    • Click the button to open the menu
    • Check the first item, then check the second
    • Mouse over the first item to see check mark disappear

    <UserControl x:Class="SilverlightApplication17.Page" 
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                 xmlns:teleriknav="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
                 xmlns:telerikbase="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
                 xmlns:telerikinput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" 
                 Width="400" 
                 Height="300"
        <Grid x:Name="LayoutRoot" 
              Background="White"
     
            <Button Content="Open menu" 
                    Width="100" 
                    Height="30"
                <teleriknav:RadContextMenu.ContextMenu> 
                    <teleriknav:RadContextMenu StaysOpen="True" 
                                               ClickToOpen="True" 
                                               EventName="Click" 
                                               Placement="Bottom"
                        <teleriknav:RadContextMenu.Items> 
                            <teleriknav:RadMenuItem Header="Item 1" 
                                                    IsCheckable="True"
                            </teleriknav:RadMenuItem> 
                            <teleriknav:RadMenuItem Header="Item 2" 
                                                    IsCheckable="True"
                            </teleriknav:RadMenuItem> 
                            <teleriknav:RadMenuItem Header="Item 3" 
                                                    IsCheckable="True"
                            </teleriknav:RadMenuItem> 
                        </teleriknav:RadContextMenu.Items> 
                    </teleriknav:RadContextMenu> 
                </teleriknav:RadContextMenu.ContextMenu> 
            </Button> 
     
        </Grid> 
    </UserControl> 
     

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Net; 
    using System.Windows; 
    using System.Windows.Controls; 
    using System.Windows.Documents; 
    using System.Windows.Input; 
    using System.Windows.Media; 
    using System.Windows.Media.Animation; 
    using System.Windows.Shapes; 
    using Telerik.Windows; 
    using Telerik.Windows.Controls; 
     
    namespace SilverlightApplication17 
        public partial class Page : UserControl 
        { 
            public Page() 
            { 
                InitializeComponent(); 
     
                this.AddHandler(RadMenuItem.CheckedEvent, new RoutedEventHandler(RadMenuItem_CheckedChanged)); 
                this.AddHandler(RadMenuItem.UncheckedEvent, new RoutedEventHandler(RadMenuItem_CheckedChanged)); 
            } 
     
            private void RadMenuItem_CheckedChanged(object sender, RoutedEventArgs e) 
            { 
                var radE = e as RadRoutedEventArgs; 
                if (radE == null || radE.OriginalSource == null
                    return
     
                var item = radE.OriginalSource as RadMenuItem; 
     
                if (item.IsChecked) 
                { 
                    //Uncheck all the other items 
                     
                    var menu = item.ParentOfType<RadContextMenu>(); 
                    menu.Items.ToList().ForEach(obj => 
                    { 
                        var item2 = menu.ItemContainerGenerator.ContainerFromItem(obj) as RadMenuItem; 
                        if (item2.IsChecked && item2 != item) 
                        { 
                            item2.IsChecked = false
                        } 
                    }); 
                } 
     
            } 
        } 
     
  2. Answer
    Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 26 Mar 2009 Link to this post

    Hello Henrik,

    I can confirm that this is a bug that will be fixed in the next service pack.
    If this is show-stopper for you just open a support ticket and I will send you the hotfix.
    Thank you for reporting this. I've updated your telerik points.

    Best wishes,
    Hristo
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 27 Mar 2009 Link to this post

    Thanks for adressing this. It's not exactly a show-stopper, but it doesn't look very good either. I've opened up a ticket to get the hotfix.
  5. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 27 Mar 2009 Link to this post

    Sorry, I just realized I posted this in the wrong forum. If anyone is confused, this thread should be in the Silverlight forum.
Back to Top