I wish to display a list of images in a cbo dropdown, show the name of the image in the textbox of the cbo, and store the path to the image back to the database.
The following code binds the cbo:
Dim logoImages As List(Of Logos) = New List(Of Logos)
Dim theLogoName As String = String.Empty
Dim theLogoPath As String = String.Empty
thisCombo.ItemsSource = Nothing
Dim listOfImages() As String = Directory.GetFiles("C:\XXX\logo", "*.*")
For i As Integer = 0 To listOfImages.Count - 1
theLogoPath = New Uri(listOfImages(i)).AbsolutePath
theLogoName = Mid(theLogoPath, 13)
logoImages.Add(New Logos() With {.logoImage = New Uri(listOfImages(i)), .logoName = theLogoName, .logoPath = theLogoPath})
Next
thisCombo.ItemsSource = logoImages
XAML:
<telerik:RadComboBox x:Name="cboLogo" FontSize="16" Background="#F6F8FA" BorderBrush="#D7D8DD"
SelectedValue="{Binding logoPath, Mode=TwoWay}"
Text="{Binding logoName}"
IsEditable="True" IsReadOnly="True" TabIndex="9"
Style="{DynamicResource RadComboBoxStyle3}" >
<telerik:RadComboBox.ItemTemplate>
<DataTemplate>
<WrapPanel Margin="0 5 0 5" Height="70">
<Image Height="65" Stretch="Fill" Source="{Binding logoImage}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</WrapPanel>
</DataTemplate>
</telerik:RadComboBox.ItemTemplate>
</telerik:RadComboBox>
The dropdown displays the images correctly. I cannot get the name of the image to display in the text part of the cbo and cannot get the path back to the database.
Can someone show me what I'm doing wrong? Thanks