My ListBox.SelectedValue returns the first selected item and not the currently selected item. (Currently selected item means that aside from the selected ITEMS, I am also displaying the last item selected)
My SelectionMode this time is Multiple not Single.
private void ListBoxSource_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var fileSelected = (FileFound)this.ListBoxSource.SelectedValue;
BitmapImage bmpImage = new BitmapImage();
bmpImage.BeginInit();
bmpImage.UriSource = new Uri(fileSelected.FileFullName, UriKind.Absolute);
bmpImage.EndInit();
Image1.Source = bmpImage;
}
Now, instead of doing it on the event, I tried Binding my Image control to the ListBoxSource BUT nothing is displayed.
Source="{Binding ElementName=ListBoxSource, Path=SelectedItems
Is theres a chance to bind it? or what is wrong with my SelectionChangedEvent code?
To get the last selected item, you’ll want the last index of the
SelectedItemsproperty.EDIT
To get the last selected item as a FileFound object, I think you want this: