Reputation: 2503
How to Bind the Image Source according to the selected item from a listbox that contains items with a property Image?
<Button Name="btn">
<Button.Header>
<StackPanel>
<Image name="img">
<StackPanel>
</Button.Header>
</Button>
Upvotes: 1
Views: 1089
Reputation:
Set the Binding like this:
<Image name="img" Source="{Binding SelectedItem.Image, ElementName=myListBox}" />
Upvotes: 0
Reputation: 35544
With the information you have provided i would do it as follows
<Button Name="btn">
<Button.Header>
<StackPanel>
<Image name="img" Source="{Binding SelectedItem.Image, ElementName=myListBox}" />
<StackPanel>
</Button.Header>
</Button>
<ListBox x:Name="myListBox">
</ListBox>
Upvotes: 4