0% found this document useful (0 votes)
22 views

Building The Basic UI Layer: Thomas Claudius Huber

This document discusses building a basic UI layer using the MVVM pattern. It recommends planning the UI layer structure, including a view, view model, and data service. It describes using the MVVM pattern with the view model acting as a bridge between the view and model. It also recommends using dependency injection, specifically Autofac, to resolve dependencies between the view, view model, and data service.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Building The Basic UI Layer: Thomas Claudius Huber

This document discusses building a basic UI layer using the MVVM pattern. It recommends planning the UI layer structure, including a view, view model, and data service. It describes using the MVVM pattern with the view model acting as a bridge between the view and model. It also recommends using dependency injection, specifically Autofac, to resolve dependencies between the view, view model, and data service.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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