Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Building the Basic UI Layer

Thomas Claudius Huber


MICROSOFT MVP (WINDOWS DEVELOPMENT)

@thomasclaudiush www.thomasclaudiushuber.com
Should you start
without requirements?
The Required User Interface
Module Plan the UI layer
Outline Know the MVVM pattern
Create the different parts
- Data Service
- ViewModel
- View

Use Dependency Injection


Plan the User Interface Layer

WPF Client Database


Friend FriendOrganizer.UI
Organizer.
View
Model
ViewModel

DataService
Friend
FriendOrganizer.DataAccess
Entity Framework SQL Server
The MVVM Pattern

View ViewModel is using Model

ListView
ItemsSource Friends FirstName

SelectedItem SelectedFriend LastName

TextBox Text FirstName

DataContext
Demo Create the MainViewModel
Implement INotifyPropertyChanged
Set the DataContext
Define the User Interface
Add Autofac for Dependency Injection

var mainWindow = new MainWindow(


new MainViewModel(
new FriendDataService()));
Add Autofac for Dependency Injection

var mainWindow = container.Resolve<MainWindow>();


The MVVM-pattern
Summary
You built a UI-layer that consists of
- View
- ViewModel
- Data Service

Autofac is used for Dependency Injection

You might also like