Suppose we have the following XAML snippet:
<ListBox x:Name="MyListBox" />
Then in the code-behind for this XAML file, we write the following in the constructor:
MyListBox.ItemsSource = new[]
{
1, 2, 3, 4, 5
};
Running the application, we get a list of numbers we enter...