uncle_scrooge
uncle_scrooge

Reputation: 429

Windows Phone Image Source binding to listbox selected item

I have a listbox of images. And a image control. When I select an image in listbox that image should be shown in image control. But its not happening.

Here is my xaml:

ScrollViewer x:Name="Sc" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto" Height="550" >

           <ListBox Name="imageList" Height="556" Width="130" HorizontalAlignment="Left" Style="{StaticResource ListBoxStyle1}" SelectionChanged="imageList_SelectionChanged">

                    <ListBox.ItemTemplate>

                    <DataTemplate>
                          <Image Source="{Binding Imgs}" Width="100" Height="100"/>

                    </DataTemplate>

                </ListBox.ItemTemplate>
                </ListBox>
        </ScrollViewer>



                <Image x:Name="Image1" Stretch="Fill" Margin="133,28,5,29" Source="{Binding Path=SelectedValue, ElementName=imageList}"/>

Upvotes: 0

Views: 1248

Answers (1)

anderZubi
anderZubi

Reputation: 6424

From your code I don't know which is the ItemSource of your ListBox element and which is the type of the items, but looking to the ItemTemplate I deduce that each element of the ListBox has a property called Imgs, pointing to the source of the images.

In that case, the binding of the Source property of your Image1 element, should point to the Imgs property of the SelectedItem:

<Image x:Name="Image1" Source="{Binding Path=SelectedItem.Imgs, ElementName=imageList}" Stretch="Fill" Margin="133,28,5,29" />

Upvotes: 3

Related Questions