Listing the customers
The next thing we need to do is to get a list of customers to display in the UI. Our approach will be to create a data provider that will query the entity framework to get our entities, which we will use as our models. To accomplish this, follow these steps:
Add a project reference from
Northwind.ViewModel
toNorthwind.Data
.Add a .NET reference to
System.Data.Entity
.Add
using
statements forSystem.Collections.Generic
,Northwind.Data
, andSystem.Data.Objects
toMainWindowViewModel
.Add the following code to
MainWindowViewModel
:private IList<Customer> _customers; public IList<Customer> Customers { get { if (_customers == null) { GetCustomers(); } return _customers; } } private void GetCustomers() { _customers = new NorthwindEntities() .Customers.ToList(); }
Update
Expander
inMainWindow
as shown in the following code:<Expander Padding="10" Margin="4" BorderBrush...