Ok, I have a potential solution for you. If it works, I'd appreciate it if you could give me a vote and mark this as an answer.
As far as I can tell, with some sort of custom behavior (which I don't know how to write yet), you'll need to use code-behind. The two key things to do are:
- assign your listbox a name, like "mylistbox"
- assign a handler for the ListBox's SelectionChanged event
You can do this with the following XAML:
<ListBox x:Name="listbox" SelectionChanged="listbox_SelChanged"
HorizontalAlignment="Left" Margin="8,8,0,8" Width="273" ItemTemplate="{DynamicResource ItemTemplate}" ItemsSource="{Binding Collection}"/>
The first two attributes are those in #1 and #2 above. In the code-behind file, you then need to add the handler for SelectionChanged. The skeleton looks like this:
public void listbox_SelChanged( object sender, RoutedEventArgs e) {}
In the code behind, you'll want to figure out which item was selected. Now, your item might differ from mine because I used a SampleDataCollection from blend to get a listbox with images and text. Just make sure you know what type it is. In the handler, you just need to get the ListBox's SelectedItem property, and this will represent whatever is selected. In my case, it was a SampleDataSource.Item, which has two properties called Property1 and Property2, where Property1 is the image.
I then created a 2nd window in my app and gave the image control a name, "image". I then set the image in this window by saying image.Source = (ImageSouce)i.Property1, where i is the SampleDatSource.Item.
I hope this makes sense. But if it doesn't, just
download my solution and check out the code . There must be better Blend-ish ways to do this, but I usually fall back to good-ol' code when all else fails. :)
I hope this helps!