Telerik RadComboBox Apply SelectionBoxTemplate OnLoad?
Basically, we created our own custom MultiSelect-ComboBox using Telerik RadComboBox and SelectionBoxTemplate to create custom text when multiple items are selected.
<ucControls:MultiSelectComboBoxBase
... >
<ucControls:RadComboBox
x:Name="RadCombo"
Text=""
Height="22"
HorizontalContentAlignment="Left"
HorizontalAlignment="Stretch"
DropDownClosed="RadCombo_DropDownClosed"
IsTextSearchEnabled="False"
IsEnabled="{Binding IsEnabled}"
CanAutocompleteSelectItems="False"
CanKeyboardNavigationSelectItems="False"
LostFocus="RadCombo_LostFocus">
<ucControls:RadComboBox.SelectionBoxTemplate>
<DataTemplate>
<Grid Background="Aqua">
<TextBlock x:Name="ComboBoxDisplay" Text="{Binding Text, ElementName=RadCombo}" />
</Grid>
</DataTemplate>
</ucControls:RadComboBox.SelectionBoxTemplate>
<ucControls:RadComboBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<CheckBox x:Name="chkBox"
Content="{Binding ItemValue}"
Tag="{Binding ItemID}"
Height="16" Margin="2"
IsChecked="{Binding IsChecked, Mode=TwoWay}"
Visibility="{Binding IsSelectAllItem, Converter={StaticResource booleanToVisibilityConverter}, ConverterParameter=NOT}"
HorizontalAlignment="Stretch" VerticalAlignment="Top"
Checked="ChkBox_Checked" Unchecked="ChkBox_Unchecked"
IsEnabled="{Binding IsEnabled, Mode=TwoWay}"/>
<HyperlinkButton
VerticalAlignment="Center" Content="{Binding ItemValue}"
Visibility="{Binding IsSelectAllItem, Converter={StaticResource booleanToVisibilityConverter}}"
Style="{StaticResource HyperlinkButtonNoBorderStyle}" Margin="3,2,0,0"
Click="HyperlinkButton_Click"
IsEnabled="{Binding IsEnabled, Mode=TwoWay}" />
</StackPanel>
</DataTemplate>
</ucControls:RadComboBox.ItemTemplate>
</ucControls:RadComboBox>
It works great, but the only problem is that it seems that the SelectionBoxTemplate is not actually being applied when the radcombobox is loaded. It only applies when clicking on a box.
When it loads, it displays: Then you click and displays the dropdown: Then you click and displays the correct text from the SelectionBoxTemplate:
Note. I made the background color of the Textblock blue to show that it is not being applied on boot.
Ideally, when it loads, it should automatically apply the SelectionBoxTemplate and display the correct information, rather than click and then click further away from the multiselectcombobox. Also, the TextBlock text is bound to the RadComboBox text because in the code behind we are setting the RadComboBox text. There is no problem with null values ββor previously unset text, because I was looking in debug mode and all the information is there, the select box template just doesn't apply until the field gets focus.
Is there some event that needs to be fired before the template is applied, or is there a way to force the template to be applied on load?
source to share
No one has answered this question yet
Check out similar questions: