Live Chat Icon For mobile
Live Chat Icon

How do I bind a string array with a ListBox?

Platform: WPF| Category: ListBox

A ListBox can be bound with a string array using the ItemsSource property of the ListBox control. The following code snippet is used to bind a string array with the ListBox.


<Window x:Class='WpfApplication4.Window1'
    Title='Window1' Height='300' Width='300' Loaded='Window_Loaded'>
       <ListBox Name='LB2'/>

private void Window_Loaded(object sender, RoutedEventArgs e)
string[] lbitems = { 'Item1', 'Item2', 'Item3', 'Item4' };
      LB2.ItemsSource = lbitems;

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.