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

Checkbox in item isn't checked

2 Answers 58 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Gilbert van Veen
Top achievements
Rank 1
Gilbert van Veen asked on 02 Mar 2011, 12:16 PM
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 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 07 Mar 2011, 04:45 PM
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!
0
Gilbert van Veen
Top achievements
Rank 1
answered on 08 Mar 2011, 08:37 AM
Hi,

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

It works perfect!.

Tags
ComboBox
Asked by
Gilbert van Veen
Top achievements
Rank 1
Answers by
Yana
Telerik team
Gilbert van Veen
Top achievements
Rank 1
Share this question
or