Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace mySillyExample
- {
- public class BookShelf
- {
- public Shelf[] myShelves{get; set;}
- }
- public class Shelf
- {
- public Book[] booksOnThisShelf{get; set;}
- }
- public class Book
- {
- public string Title {get; set;};
- public string Author{get; set;};
- public string ISBN {get; set;};
- }
- }
- <ListBox Height="154" HorizontalAlignment="Left"
- ItemsSource="{Binding Path=BookShelf.myShelves}"
- Margin="171,475,0,0" VerticalAlignment="Top" Width="333" >
- <ListBox.ItemTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding Path=booksOnThisShelf.[0].Title}" />
- </DataTemplate>
- <ListBox.ItemTemplate>
- </ListBox>
- //ViewModelBase should be a base class that implements INotifyPropertyChanged
- public class MyViewModel : ViewModelBase
- {
- public readonly IDataProvider _provider;
- public MyViewModel(IDataProvider provider)
- {
- _provider = provider ?? (some default provider);
- }
- public IList<String> Titles
- {
- get
- {
- var q = from shelves in _provider.GetBookShelves()
- from books in shelves.booksOnThisShelf
- select books.Title;
- return q as List<String>;
- }
- }
- }
Add Comment
Please, Sign In to add comment