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

Checking the nth List item

1 Answer 79 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Purna
Top achievements
Rank 1
Purna asked on 01 Dec 2017, 03:32 AM

I want to check the nth item of the ComboBox with CheckBox dynamically. How can this be achieved?

I tried the following and an exception is thrown

radCombo.Items(n).IsSelected = True

 

The XAML is as followed:

 <DataTemplate x:Key="CheckBoxItemTemplate">
            <CheckBox Content="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadComboBoxItem}, Path=Content}" 
                      IsChecked="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadComboBoxItem}, Path=IsSelected}" 
                      telerik:TouchManager.ShouldSuspendMousePromotion="True" Click="CheckBox_Click"/>
        </DataTemplate>

 

<telerik:RadComboBox Name="radCombo" Height="30" Canvas.Left="650" Canvas.Top="55" Width=" 200" Background="White" AllowMultipleSelection="True" EmptyText="Select "
                                         MultipleSelectionSeparator=","  IsReadOnly="True" ItemTemplate="{StaticResource CheckBoxItemTemplate}" >
                    </telerik:RadComboBox>

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 05 Dec 2017, 11:56 AM
Hello Purna,

When using ItemTemplate you could set the TextSearch.TextPath property in order to indicate which is the searchable property and this property will be displayed as well when an item is selected.

I have created sample project which demonstrates how to implement checkbox in the template of the combo box items in order to select them. You can find the project attached to this reply.

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
ComboBox
Asked by
Purna
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or