Вам просто нужно настроить коллекцию с вашими элементами в вашем DataContext и установить ее как ListBox.ItemsSource.Затем он заполнит ваш DataTemplate.
См. Например:
<Grid>
<Grid.Resources>
<src:Customers x:Key="customers"/>
</Grid.Resources>
<ListBox ItemsSource="{StaticResource customers}" Width="250" Margin="0,5,0,10"
DisplayMemberPath="LastName"/>
</Grid>
И:
public class Customer
{
public String FirstName { get; set; }
public String LastName { get; set; }
public String Address { get; set; }
public Customer(String firstName, String lastName, String address)
{
this.FirstName = firstName;
this.LastName = lastName;
this.Address = address;
}
}
public class Customers : ObservableCollection<Customer>
{
public Customers()
{
Add(new Customer("Michael", "Anderberg",
"12 North Third Street, Apartment 45"));
Add(new Customer("Chris", "Ashton",
"34 West Fifth Street, Apartment 67"));
Add(new Customer("Cassie", "Hicks",
"56 East Seventh Street, Apartment 89"));
Add(new Customer("Guido", "Pica",
"78 South Ninth Street, Apartment 10"));
}
}
Пример источника: http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.itemssource(v=vs.95).aspx
Редактировать: согласно обсуждению в комментариях, может быть, вам нужен только простой ItemsControl (так как вам не нужно сохранять выбранный элемент или даже лучше обрабатывать множественный выбор, для чего предназначен ListBox).
Например:
<ItemsControl ItemsSource="{Binding NavigateItems}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Content="{Binding Label}"
Command="{Binding ButtonCommand}"
CommandParameter="{Binding URL}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
И:
public class NavigateItem
{
public String Label { get; set; }
public String URL { get; set; }
public NavigateItem(String label, String url)
{
this.Label = label;
this.URL = url;
}
}
public class NavigateItems : ObservableCollection<NavigateItem>
{
public NavigateItems()
{
Add(new NavigateItem("Google", "http://www.google.com");
Add(new NavigateItem("Bing", "http://www.bing.com");
}
}
И, конечно, настройка ButtonCommand для перехода к URL-адресу, переданному в параметре, но это зависит от того, как выустановка ViewModel / привязок.