Programatically Add Listbox with Image and Text in Silverlight using VB.NET
Step 1) Add listbox to xaml.
Step 2) Upload images to Silverlight Project.
Step 3) Add Listbox Items Programatically , it includes images(shown above and with text).
Dim panel As StackPanel = New StackPanel()
panel.Orientation = Orientation.Horizontal
Dim img As Image = New Image()
img.Source = New BitmapImage(New Uri("india.jpg", UriKind.Relative))
img.Height = 50
img.Width = 50
Dim blk As TextBlock = New TextBlock()
blk.Text = "India"
blk.VerticalAlignment = System.Windows.VerticalAlignment.Center
blk.HorizontalAlignment = System.Windows.HorizontalAlignment.Right
panel.Children.Add(img) panel.Children.Add(blk) listBox1.Items.Add(panel)
panel = New StackPanel()
img = New Image()
img.Source = New BitmapImage(New Uri("australia.jpg", UriKind.Relative))
img.Height = 50
img.Width = 50
blk = New TextBlock()
blk.Text = "Australia"
panel.Children.Add(img) panel.Children.Add(blk) listBox1.Items.Add(panel)
panel = New StackPanel()
img = New Image()
img.Source = New BitmapImage(New Uri("america.jpg", UriKind.Relative))
img.Height = 50
img.Width = 50
blk = New TextBlock()
blk.Text = "america"
panel.Children.Add(img) panel.Children.Add(blk) listBox1.Items.Add(panel)
panel = New StackPanel()
img = New Image()
img.Source = New BitmapImage(New Uri("uk.jpg", UriKind.Relative))
img.Height = 50
img.Width = 50
blk = New TextBlock()
blk.Text = "UK"
panel.Children.Add(img) panel.Children.Add(blk) listBox1.Items.Add(panel)
panel = New StackPanel()
img = New Image()
img.Source = New BitmapImage(New Uri("sa.jpg", UriKind.Relative))
img.Height = 50
img.Width = 50
blk = New TextBlock()
blk.Text = "SA"
Dim panel.Children.AddCType(As panel.Children.Add(img), blk)
listBox1.Items.Add(panel)
Step 4) Run the Application.
Tags:Programatically Add Listbox with Image and Text in Silverlight 5 using VB.NET,Programatically Add Listbox with Image and Text in Silverlight 5,Listbox with Text and Image in Silverlight, Silverlight Listbox with Text and Image Programatically,Silverlight Listbox





No comments:
Post a Comment