Completed
Last Updated: 17 Nov 2022 07:11 by ADMIN
Release LIB 2022.3.1121 (21 Nov 2022)
Stenly
Created on: 07 Nov 2022 16:25
Category: ComboBox
Type: Bug Report
0
ComboBox: In a multiple selection scenario, having a type converter does not correctly visualize the selected items

The selected items of the RadComboBox will not be displayed correctly if the ItemsSource is bound to a collection of enums that are converted via a custom EnumConverter.

Currently, you could work around this behavior by implementing a custom DataTemplate for the MultipleSelectionBoxTemplate property of RadComboBox:

<telerik:RadComboBox x:Name="comboBox"
                     AllowMultipleSelection="True">
    <telerik:RadComboBox.MultipleSelectionBoxTemplate>
        <DataTemplate>
            <ItemsControl ItemsSource="{Binding ElementName=comboBox, Path=SelectedItems}"
                          AlternationCount="{Binding RelativeSource={RelativeSource Self}, Path=Items.Count}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock x:Name="commaTextBlock" Text=", "/>
                            <TextBlock Text="{Binding}" HorizontalAlignment="Left"/>
                        </StackPanel>
                        <DataTemplate.Triggers>
                            <Trigger Property="ItemsControl.AlternationIndex" Value="0">
                                <Setter Property="Visibility" TargetName="commaTextBlock" Value="Collapsed" />
                            </Trigger>
                        </DataTemplate.Triggers>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </DataTemplate>
    </telerik:RadComboBox.MultipleSelectionBoxTemplate>
</telerik:RadComboBox>

0 comments