What is the DataContext of RadComboBox.MultipleSelectionBoxTemplate?

1 Answer 173 Views
ComboBox
Joshua
Top achievements
Rank 1
Joshua asked on 18 Jun 2021, 03:22 PM
I have a data-driven application architecture and my expectation is that MultipleSelectionBoxTemplate shares the same DataContext as the parent RadComboBox because it does not apply to any particular item. This is very confusing.

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 23 Jun 2021, 07:04 AM

Hello Joshua,

The DataContext passed to the MultipleSelectionBoxTemplate is the value of the SelectionBoxItem property of RadComboBox. The SelectionBoxItem property is synced with the Text property of the control when the multiple selection is enabled. In other words, the DataContext is a string. 

If you need to have the DataContext of the RadComboBox control, you can adjust this explicitly. For example:

<telerik:RadComboBox x:Name="comboBox" AllowMultipleSelection="True">
	<telerik:RadComboBox.MultipleSelectionBoxTemplate>
		<DataTemplate>
			<TextBlock Text="{Binding ElementName=comboBox, Path=DataContext}" />
		</DataTemplate>
	</telerik:RadComboBox.MultipleSelectionBoxTemplate>
</telerik:RadComboBox>

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
ComboBox
Asked by
Joshua
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or