This question is locked. New answers and comments are not allowed.
Sometimes, and I'm not exactly sure when, the SelectionBoxItemTemplate is not applied until the combobox is opened, even though an item is selected. See the code below.
| <UserControl x:Class="TelerikTestProject.SilverlightControl4" |
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| xmlns:telerikbase="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" |
| xmlns:telerikinput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" |
| xmlns:teleriknav="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" |
| xmlns:local="clr-namespace:TelerikTestProject" |
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| Width="400" |
| Height="300"> |
| <Grid x:Name="LayoutRoot" |
| Background="White"> |
| <Grid.Resources> |
| <telerikbase:ContainerBindingCollection x:Name="UserItemBindings"> |
| <telerikbase:ContainerBinding PropertyName="IsSelected" |
| Binding="{Binding IsSelected, Mode=TwoWay}" /> |
| </telerikbase:ContainerBindingCollection> |
| <DataTemplate x:Key="UserItemTemplate" |
| telerikbase:ContainerBinding.ContainerBindings="{StaticResource UserItemBindings}"> |
| <TextBlock Text="{Binding FirstName}"></TextBlock> |
| </DataTemplate> |
| <DataTemplate x:Key="UserItemTemplate_SelectionBox"> |
| <TextBlock Text="{Binding FirstName}"></TextBlock> |
| </DataTemplate> |
| </Grid.Resources> |
| <telerikinput:RadComboBox x:Name="RCBUsers" |
| ItemsSource="{Binding Users}" |
| VerticalAlignment="Top" |
| HorizontalAlignment="Left" |
| ItemTemplate="{StaticResource UserItemTemplate}" |
| SelectionBoxItemTemplate="{StaticResource UserItemTemplate_SelectionBox}"> |
| </telerikinput:RadComboBox> |
| </Grid> |
| </UserControl> |
| using System; |
| using System.Collections.Generic; |
| using System.Linq; |
| using System.Net; |
| using System.Windows; |
| using System.Windows.Controls; |
| using System.Windows.Documents; |
| using System.Windows.Input; |
| using System.Windows.Media; |
| using System.Windows.Media.Animation; |
| using System.Windows.Shapes; |
| using Telerik.Windows.Controls; |
| using System.Collections.ObjectModel; |
| namespace TelerikTestProject |
| { |
| public partial class SilverlightControl4 : UserControl |
| { |
| public SilverlightControl4() |
| { |
| InitializeComponent(); |
| var users = UserInfo2.Get10(); |
| users[3].IsSelected = true; |
| var container = new UserContainer() { Users = users }; |
| this.DataContext = container; |
| } |
| } |
| public class UserContainer |
| { |
| public ObservableCollection<UserInfo2> Users { get; set; } |
| } |
| public class UserInfo2 |
| { |
| public string FirstName { get; set; } |
| public bool IsSelected { get; set; } |
| public UserInfo2() |
| { |
| } |
| public static ObservableCollection<UserInfo2> Get10() |
| { |
| ObservableCollection<UserInfo2> users = new ObservableCollection<UserInfo2>(); |
| for (int i = 0; i < 100; i++) |
| { |
| users.Add(new UserInfo2() |
| { |
| FirstName = String.Format("FirstName {0}", i), |
| }); |
| } |
| return users; |
| } |
| } |
| } |