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

Check/uncheck bug in context menu

3 Answers 73 Views
Menu
This is a migrated thread and some comments may be shown as answers.
hwsoderlund
Top achievements
Rank 1
hwsoderlund asked on 26 Mar 2009, 10:28 AM
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
                    } 
                }); 
            } 
 
        } 
    } 
 

3 Answers, 1 is accepted

Sort by
0
Accepted
Hristo
Telerik team
answered on 26 Mar 2009, 06:03 PM
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.
0
hwsoderlund
Top achievements
Rank 1
answered on 27 Mar 2009, 07:35 AM
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.
0
hwsoderlund
Top achievements
Rank 1
answered on 27 Mar 2009, 07:37 AM
Sorry, I just realized I posted this in the wrong forum. If anyone is confused, this thread should be in the Silverlight forum.
Tags
Menu
Asked by
hwsoderlund
Top achievements
Rank 1
Answers by
Hristo
Telerik team
hwsoderlund
Top achievements
Rank 1
Share this question
or