Nithila Devi

Nithila Devi

  • NA
  • 1
  • 6.4k

how to bind image dynamically inside listbox

Jun 10 2010 12:43 AM
 
My code is here:
 <ListBox  VerticalAlignment="Stretch" SelectionMode="Extended"  Height="600" Width="313">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Height="25" Width="25">
                                <Image Source="{Binding img}" >
                                    <Image.RenderTransform>
                                        <ScaleTransform ScaleX="1" ScaleY="1" />
                                    </Image.RenderTransform>

                                </Image>
                          
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                
                </ListBox>

And I add code

 List<Person> myl = new List<Person>();

 myl.Add(new Person { img = "Images/s1.jpeg" });
 myl.Add(new Person { img = "Images/s2.jpeg" });
listBox.ItemsSource = myl;

The image not binded.There is no error while running.



Answers (1)