namespace testlistbox
{
public partial class MainPage : UserControl
{
public MainPage()
{
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
InitializeComponent();
}
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
PersonList.DataContext = MakePersonList();
PersonList.SelectedIndex = -1;
}
private static List MakePersonList()
{
return (new List()
{
new Person() { FirstName = "John", LastName = "Smith" },
new Person() { FirstName = "John", LastName = "Jones" }
});
}
}
class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
}
|