Basic Library for WPF and Silverlight | ComponentOne
WPF and Silverlight Edition Basic Library / Menu and ContextMenu / Menu and ContextMenu Features / Checkable Menu Items / Mutually Exclusive Checkable Menu Items
In This Topic
    Mutually Exclusive Checkable Menu Items
    In This Topic

    With the C1Menu control, you can create a list of checkable menu items that are grouped together so that only one item can be checked at a time.

    Complete the following steps:

    1. Add IsCheckable="True" and GroupName="CheckableGroup" to the <c1:C1MenuItem> tag of each menu item you wish to add to the group of mutually exclusive checkable items.
    2. Run the program and click the first item in the group. Observe that a check is added to the menu item. Now click the second item in the group and observe that the check is removed from the first item and then added to the second item.

    Complete the following steps:

    1. Set the x:Name property of each C1MenuItem you wish to add to the group of mutually exclusive checkable items.
    2. Open the MainPage.xaml.cs page.
    3. Set the IsCheckable and GroupName property of each menu item, replacing "ItemName" with the value of the menu item's x:Name property.
    Visual Basic
    Copy Code
    ItemName.IsCheckable = True
    

     

    C#
    Copy Code
    ItemName.IsCheckable = true;
    
    1. Run the program and click the first item in the group. Observe that a check is added to the menu item. Now click the second item in the group and observe that the check is removed from the first item and then added to the second item.

    Complete the following steps:

    1. In Design view, select the first C1MenuItem you wish to make checkable and then set the following properties in the Properties window:

    Set the IsCheckable property to True.

    Set the GroupName property to a string, such as "CheckableGroup".

    1. Repeat step 1 for any other menu items you wish to add to the group of mutually exclusive checkable items.
    2. Run the program and click the first item in the group. Observe that a check is added to the menu item. Now click the second item in the group and observe that the check is removed from the first item and then added to the second item.