vijay rags

vijay rags

  • NA
  • 68
  • 163.4k

Re:How to bind ListBox in silverlight3 with items from DB

Sep 20 2011 5:27 AM
Hi,
 
     How to bind the ListBox in silverlight3 with items from DB by calling a service which return values.

 <ListBox x:Name="ListBox2" Grid.Row="12" Grid.Column="1" Width="200" Height="200"  ScrollViewer.VerticalScrollBarVisibility="Visible"
                             SelectionMode="Extended" SelectionChanged="ListBox2_SelectionChanged" Margin="10" >
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Vertical">
                                    <TextBlock Text="{Binding Name}" Margin="5" Foreground="Black"></TextBlock>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

This is what i did and in the code behind called the Service and ListBox2.DataContext=Result of the Service.

Please help me out.

Thanks in advance.




Answers (2)