Multiple view models

Another important task in real projects is combining several views on the same page. In other words, you separated Models and their corresponding separated Views (in different files), but you want to display all Views at the same time. So, let's consider the following example.

The Model will be as follows:

public class BookModel { public string Title { get; set; } public string Author { get; set; } } public class LibraryModel { public string LibraryName { get; set; } public List<BookModel> Books { get; set; } } public class ReaderModel { public string FirstName { get; set; } public string LastName { get; set; } public BookModel FavoriteBook { get; set; } } public class MultipleViewModel { public LibraryModel LibraryModel { get; ...

Get Getting Started with Knockout.js for .NET Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.