This is a migrated thread and some comments may be shown as answers.

Image is not displaying in the Combobox

1 Answer 84 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Civbaron
Top achievements
Rank 1
Civbaron asked on 08 Oct 2010, 01:40 AM
Hi,

I am trying to display an image and a textblock in a radcombo box control nested within a radtreeview. The radcombox's itemssource is set to value that contains a text property and bitmapimage. I set the source for the image to the bitmapimage stored in the radcombox's itemsource. When the radcombox is expanded and displayed the text displays but the image does not display.

Here is a sample of the radcomboxes item templates:

 

 

 

<telerik:RadComboBox x:Name="rcbImages" VerticalAlignment="Center" IsEnabled="False" SelectedValue="{Binding Condition}" Visibility="Hidden" telerik:StyleManager.Theme="Office_Blue" Width="150" Grid.Column="5">

 

 

 

 

<telerik:RadComboBox.SelectionBoxTemplate>

 

 

 

 

<DataTemplate>

 

 

 

 

<Grid>

 

 

 

 

<Grid.ColumnDefinitions>

 

 

 

 

<ColumnDefinition Width="*" />

 

 

 

 

<ColumnDefinition Width="40" />

 

 

 

 

</Grid.ColumnDefinitions>

 

 

 

 

<TextBlock Grid.Column="1" Text="{Binding Key.Description}" />

 

 

 

 

<Image Grid.Column="0" Source="{Binding Value}">

 

 

 

 

</Image>

 

 

 

 

</Grid>

 

 

 

 

</DataTemplate>

 

 

 

 

</telerik:RadComboBox.SelectionBoxTemplate>

 

 

 

 

<telerik:RadComboBox.ItemTemplate>

 

 

 

 

<DataTemplate>

 

 

 

 

<Grid>

 

 

 

 

<Grid.ColumnDefinitions>

 

 

 

 

<ColumnDefinition Width="*" />

 

 

 

 

<ColumnDefinition Width="40" />

 

 

 

 

</Grid.ColumnDefinitions>

 

 

 

 

<TextBlock Grid.Column="1" Text="{Binding Description}" />

 

 

 

 

<Image Grid.Column="0" Source="{Binding Value}" Initialized="Image_Initialized" Loaded="Image_Loaded" ImageFailed="Image_ImageFailed">

 

 

 

 

</Image>

 

 

 

 

</Grid>

 

 

 

 

</DataTemplate>

 

 

 

 

</telerik:RadComboBox.ItemTemplate>

 

 

 

 

</telerik:RadComboBox>

 



And here is a sample of the code to get the image and the setting of the itemsource for the combox:

 

 

BitmapImage bitimage = new BitmapImage();

 

bitimage.BeginInit();

bitimage.StreamSource =

 

new System.IO.MemoryStream(images[i].ImageValue);

 

bitimage.EndInit();

images[i].Image = bitimage;

 

 

 

Dictionary<ImageType, BitmapImage> dicImages = new Dictionary<ImageType, BitmapImage>();

 

 

 

for (int i = 0; i < images.Count; i++)

 

{

dicImages.Add(images[i], images[i].Image);

}

combo.SelectedValuePath =

 

"Key.ImageKey";

 

combo.ItemsSource = dicImages;

combo.IsEnabled =

 

true;

Any help would be greatly appreciated.

Thanks,

Jonathan

 

1 Answer, 1 is accepted

Sort by
0
Civbaron
Top achievements
Rank 1
answered on 08 Oct 2010, 01:52 AM
Hi I have solved my problem with the image not displaying.
Tags
ComboBox
Asked by
Civbaron
Top achievements
Rank 1
Answers by
Civbaron
Top achievements
Rank 1
Share this question
or