Checkbox in item isn't checked

3 posts, 0 answers
  1. Gilbert van Veen
    Gilbert van Veen avatar
    68 posts
    Member since:
    Oct 2009

    Posted 02 Mar 2011 Link to this post

    Hi,

    I have a radcombobox with items which are filled by my own routine.
    In the combobox there is a context menu with two options:

    - Check all
    - Uncheck all

    When I select one of the above I want to itterate trough the items and set the checkbox to true or false. I call my routine and I see that the Entitype.IsChecked is set but the checkbox in the combobox isn't updated?

    <telerikInput:RadComboBox 
                                        x:Name="Tra_EntityTypeList" Width="150" Height="25" HorizontalAlignment="Left" Tag="EntityList" 
                                        ClearSelectionButtonContent="None" IsEnabled="True" FontStyle="Italic" EmptyText="Selection" MaxDropDownHeight="225" DropDownClosed="ItemsChecked">
                                <telerikInput:RadComboBox.ItemTemplate>
                                    <DataTemplate x:Name="EntityTemplate">
                                        <Grid Margin="0" Width="200">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="25"/>
                                                <ColumnDefinition Width="175" />
                                            </Grid.ColumnDefinitions>
                                            <Grid.RowDefinitions>
                                                <RowDefinition />
                                            </Grid.RowDefinitions>
                                            <CheckBox Grid.Column="0" Margin="0" Name="CheckBoxForEntityType" IsChecked="{Binding IsChecked, Mode=TwoWay}"/>
                                            <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Description}" Tag="EntityType">
                                                <!--Context menu-->
                                                <telerik:RadContextMenu.ContextMenu>
                                                    <telerik:RadContextMenu Opened="RadContextMenu_Opened" ItemClick="RadContextMenu_ItemClick">
                                                        <telerik:RadContextMenu.Items>
                                                            <telerik:RadMenuItem Header="Select all" Tag="EntSelectAll" />
                                                            <telerik:RadMenuItem Header="Select none" Tag="EntSelectNone" />
                                                        </telerik:RadContextMenu.Items>
                                                    </telerik:RadContextMenu>
                                                </telerik:RadContextMenu.ContextMenu>
                                            </TextBlock>
                                        </Grid>
                                    </DataTemplate>
                                </telerikInput:RadComboBox.ItemTemplate>
                            </telerikInput:RadComboBox>

    The code behind is:

    switch (_Type)
                {
                    case "EntityType":
                        int i = 0;
                        foreach (EntityType MySelectedEntityType in Tra_EntityTypeList.Items)
                        {
                            MySelectedEntityType.IsChecked = true;
                            i++;
                        }
                        break;
                }

    I hope someone can help me with this.
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 07 Mar 2011 Link to this post

    Hello Gilbert van Veen,

    You should implement INotifyPropertyChanged interface in order to notify that IsChecked property has been changed and thus to force the combobox items to take the new value. I've attached an example based on your code to demonstrate the approach.

    All the best,
    Yana
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. DevCraft banner
  4. Gilbert van Veen
    Gilbert van Veen avatar
    68 posts
    Member since:
    Oct 2009

    Posted 08 Mar 2011 Link to this post

    Hi,

    Many thanks!! I totally forgot to use the INotifyChanged option.

    It works perfect!.

Back to Top