Hi everyone
I need to give each item in a RadCombobox a very specific color..
My XAML is:
<telerik:RadComboBox x:Name="cmbToolTypeForLoad" ItemsSource="{Binding ToolTypeForCmb}" DisplayMemberPath="Description" Margin="46,29,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="421" Height="48" >
<ComboBoxItem>
<Style TargetType="ComboBoxItem">
<Setter Property="Background" Value="{Binding Color}"/>
</Style>
</ComboBoxItem>
</telerik:RadComboBox>
to populate my combobox I had to convert the integer color stored in SQL:
public partial class ToolTypeForCmb
{
public int ToolTypeId { get; set; }
public string Description { get; set; }
public Brush Color { get; set; }
}
List<ToolType> toolTypes = toolTypeService.GetAll(MachineryCode);
List<ToolTypeForCmb> toolTypeForCmb = new List<ToolTypeForCmb>();
foreach (ToolType toolType in toolTypes)
{
ToolTypeForCmb ttfcmb = new ToolTypeForCmb();
ttfcmb.Color = UtilityService.ConvertIntToColorBrush(toolType.Color);
ttfcmb.Description = toolType.Description;
ttfcmb.ToolTypeId = toolType.ToolTypeId;
toolTypeForCmb.Add(ttfcmb);
}
cmbToolTypeForLoad.ItemsSource = toolTypeForCmb;
Unfortunately, it generates an error when I assign the item.
"The collection of items must be empty before you can use ItemsSource".
how can i solve?
thanks