I've tried to bind my image into the listbox i've created, yet it is just not working, can any1 help out with my problems so that i can actually bind the image into "ListBoxItem" as shown in the code below.
Code behind:
public object ImageSource
{
get
{
Image finalImage = new Image();
BitmapImage logo = new BitmapImage();
logo.BeginInit();
logo.UriSource = new Uri(@"/images/food1.bmp", UriKind.Relative);
logo.EndInit();
finalImage.Source = logo;
return logo;
}
}
XAML:
<ListBox Grid.ColumnSpan="2">
<ListBox.Resources>
<Style TargetType="{x:Type Image}">
<Setter Property="Width" Value="100"/>
<Setter Property="Height" Value="100"/>
<EventSetter Event="MouseLeftButtonDown" Handler="DragImage"/>
</Style>
</ListBox.Resources>
<ListBoxItem>
<Image Source="{Binding Path=ImageSource}" Width="197" Height="120" Margin="0,0,0,0" />
</ListBoxItem>
</ListBox>