SlideShare une entreprise Scribd logo
1  sur  45
MvvmQuickCross
lightweight cross-platform
Accelerates
code sharing
in control
NuGet GitHub
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
Model
• Entities (POCO)
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
Model
• Entities (POCO)
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Navigator
• Navigate to view
implementation
Entry
Point
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Navigator
• Navigate to view
implementation
Entry
Point
Main View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Main ViewModel
• Properties
• Commands
• INotifyPropertyChanged
SubB ViewModel
• Properties
• Commands
• INotifyPropertyChanged
SubA ViewModel
• Properties
• Commands
• INotifyPropertyChanged
SubB View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
SubA View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Composite ViewModels are also possible:
class MainViewModel : ViewModelBase {
List<ItemViewModel> MyItems /* Data-Bindable property
}
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
public int Count /* One-way data-bindable property
generated with propdb1 snippet …
public string MyProperty /* Two-way data-bindable
property generated with propdb2 snippet …
public string MyProperty2 /* Two-way data-bindable
property that calls custom code in
OnMyProperty2Changed() from setter, generated with
propdb2c snippet …
/* One-way data-bindable property generated with
propdbcol snippet…
public ObservableCollection<string> MyCollection
public bool MyCollectionHasItems
protected void UpdateMyCollectionHasItems()
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
public RelayCommand DoSomethingCommand /* Data-bindable
command that calls DoSomething(), generated with cmd
snippet …
private void DoSomething()
{
// TODO: Implement DoSomething()
throw new NotImplementedException();
}
public RelayCommand EditItemCommand /* Data-bindable
command with parameter that calls EditItem(), generated
with cmdp snippet …
private void EditItem(object parameter)
{
var item = (Item)parameter;
// TODO: Implement EditItem()
throw new NotImplementedException();
}
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
// Design-time data support
#if DEBUG
namespace MyApp.ViewModels.Design
{
public class MyModelDesign : MyViewModel
{
public MyModelDesign()
{
// TODO: Initialize the view model with
hardcoded design-time data
}
}
}
#endif
Note: Design-data can initially also be used at runtime
for fast application prototyping, before any services or
models are implemented.
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
public abstract class ViewModelBase :
INotifyPropertyChanged
{
public event PropertyChangedEventHandler
PropertyChanged;
protected virtual void RaisePropertyChanged(
string propertyName)
{ … }
}
public class RelayCommand : ICommand
{
public RelayCommand(Action handler, …
public RelayCommand(Action<object> handler, …
public bool IsEnabled { … }
}
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
<phone:PhoneApplicationPage
xmlns:vm=
"clr-namespace:MyApp.Shared.ViewModels.Design;
assembly=MyApp.Shared.wp"
d:DataContext="{d:DesignInstance
Type=vm:MyViewModelDesign,
IsDesignTimeCreatable=True }"
<TextBox Text="{Binding Title, Mode=TwoWay}" …
</phone:PhoneApplicationPage>
public partial class MyView : PhoneApplicationPage
{
public MyView()
{
InitializeComponent();
DataContext = MyApplication.Instance.MyViewModel;
}
}
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
Model
• Entities (POCO)
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
public class ClientLotUpdate
{
public decimal CurrentPrice { get; set; }
public int ProgressRemaining { get; set; }
public RemainingTime TimeRemaining { get; set; }
public ClientLotUpdate()
{
TimeRemaining = new RemainingTime();
}
}
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
ServiceAgent
• Service Entities
• Service Events
• Service Methods
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
public class ClientLotUpdate
{
public decimal CurrentPrice { get; set; }
public int ProgressRemaining { get; set; }
public RemainingTime TimeRemaining { get; set; }
public ClientLotUpdate()
{
TimeRemaining = new RemainingTime();
}
}
Note that in simple cases service entities defined in
the service contract can be used directly as the
‘model’.
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
public class LotUpdatedEventArgs : EventArgs
{
public ClientLotUpdate clientLotUpdate { get; set; }
}
public event EventHandler<LotUpdatedEventArgs>
ActiveLotUpdated;
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
public class PlaceBidRequest
{
public int LotId { get; set; }
public decimal Price { get; set; }
}
public Task RaisePlaceBidAsync(PlaceBidRequest
placeBidRequest)
{
return _hubProxy.Invoke(
"PlaceBid",
new object[] { placeBidRequest });
}
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
public class AuctionApplication
{
void ContinueToAuction()
void ContinueToCheckout(Basket basket)
void ContinueToOrderConfirmed()
void ContinueToProductList()
void ContinueToProductPage(ClientLot product)
void UserWantsToSignIn()
bool IsUserLoggedIn()
…
}
The ViewModel only uses the application to initiate
navigation and to obtain relevant application state.
ViewModels do not reference or modify other viewmodels.
Exception: contained view models; e.g. a collection of
ItemViewModel.
ViewModels can pass parameters to the application, which
in turn can use those to initialize other view models.
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
public abstract class ApplicationBase {
public static Task RunOnUIThread(Action action)
public object CurrentNavigationContext { get; set; }
}
class MyApplication : ApplicationBase {
public static MyApplication Instance { get … }
public MyViewModel MyViewModel { get; private set; }
public void ContinueToItem(Item item = null)
{
if (MyViewModel == null)
MyViewModel = new MyViewModel(_itemService);
MyViewModel.Initialize(item);
RunOnUIThread(() => _navigator.NavigateToMyView(
CurrentNavigationContext));
}
}
Application initializes viewmodel and then calls
navigator for platform-specific view navigation.
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Navigator
• Navigate to view
implementation
public interface IMyAppNavigator
{
void NavigateToMyView(object navigationContext);
void NavigateToOtherView(object navigationContext);
}
The navigator implementation is platform specific – it
knows what type of object navigationContext is.
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Navigator
• Navigate to view
implementation
Entry
Point
public partial class App : Application {
public static MyApplication EnsureMyApplication(
Frame navigationContext) {
return MyApplication.Instance ??
new MyApplication(new MyNavigator(),
navigationContext);
}
void Application_Launching(…) {
EnsureMyApplication(RootFrame).ContinueToItemList(
skipNavigation: true);
}
void Application_Activated(…) {
EnsureMyApplication(RootFrame);
}
}
The entry point is platform specific
(navigationContext, here a WP Frame) and creates
platform specific service instances, such as the
Navigator.
ViewModel
• Properties
• Commands
• INotifyPropertyChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Navigator
• Navigate to view
implementation
Entry
Point
class MyNavigator : IMyNavigator
{
void Navigate(object navigationContext, string uri)
{
((Frame)navigationContext).Navigate(
new Uri(uri, UriKind.Relative));
}
void NavigateToMyView(object navigationContext)
{
Navigate(navigationContext, "/MyView.xaml");
}
…
}
The navigator is platform specific (navigationContext,
here a WP Frame).
ViewModel
• Properties
• Commands
• INotifyPropertyChanged, INoti
fyCollectionChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Navigator
• Navigate to view
implementation
Entry
Point
Runtime flow: Application starts with AuctionView, user
places bid and navigates to CheckoutView.
1. Entrypoint is called, creates Navigator and
Application instances.
2. Application ctor creates ServiceAgent and
AuctionViewModel + ProductsViewModel
3. Entry Point calls
MyApplication.Instance.NavigateToAuctionView()
4. Navigator calls platform-specific navigate to
AuctionView
5. View class gets ViewModel from Application.Instance
6. On platforms without data binding, the view
subscribes itself to PropertyChanged on
ViewModel, for select (groups of) properties (it is
not necessary to bind to each individual property).
Also the commands of the views are invoked from code
in an event handler.
7. The viewmodel is updated by events from service and
commands from view. The view updates w data binding.
8. A command on a viewmodel can invoke the ContinueTo…
method on application … continue with step 3.
1
2
3
4
5 6
78
2
ViewModel
• Properties
• Commands
• INotifyPropertyChanged, INoti
fyCollectionChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Navigator
• Navigate to view
implementation
Entry
Point
Runtime flow: Application starts with AuctionView, user
places bid and navigates to CheckoutView.
1. Entrypoint is called, creates Navigator and
Application instances.
2. Application ctor creates ServiceAgent and
AuctionViewModel + ProductsViewModel
3. Entry Point calls
MyApplication.Instance.NavigateToAuctionView()
4. Navigator calls platform-specific navigate to
AuctionView
5. View class gets ViewModel from Application.Instance
6. On platforms without data binding, the view
subscribes itself to PropertyChanged on
ViewModel, for select (groups of) properties (it is
not necessary to bind to each individual property).
Also the commands of the views are invoked from code
in an event handler.
7. The viewmodel is updated by events from service and
commands from view. The view updates w data binding.
8. A command on a viewmodel can invoke the ContinueTo…
method on application … continue with step 3.
1
2
3
4
5 6
78
2
ViewModel
• Properties
• Commands
• INotifyPropertyChanged, INoti
fyCollectionChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Navigator
• Navigate to view
implementation
Entry
Point
Runtime flow: Application starts with AuctionView, user
places bid and navigates to CheckoutView.
1. Entrypoint is called, creates Navigator and
Application instances.
2. Application ctor creates ServiceAgent and
AuctionViewModel + ProductsViewModel
3. Entry Point calls
MyApplication.Instance.NavigateToAuctionView()
4. Navigator calls platform-specific navigate to
AuctionView
5. View class gets ViewModel from Application.Instance
6. On platforms without data binding, the view
subscribes itself to PropertyChanged on ViewModel,
for select (groups of) properties (it is not
necessary to bind to each individual property). Also
the commands of the views are invoked from code in an
event handler.
7. The viewmodel is updated by events from service and
commands from view. The view updates w data binding.
8. A command on a viewmodel can invoke the ContinueTo…
method on application … continue with step 3.
1
2
3
4
5 6
78
2
ViewModel
• Properties
• Commands
• INotifyPropertyChanged, INoti
fyCollectionChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Navigator
• Navigate to view
implementation
Entry
Point
Runtime flow: Application starts with AuctionView, user
places bid and navigates to CheckoutView.
1. Entrypoint is called, creates Navigator and
Application instances.
2. Application ctor creates ServiceAgent and
AuctionViewModel + ProductsViewModel
3. Entry Point calls
MyApplication.Instance.NavigateToAuctionView()
4. Navigator calls platform-specific navigate to
AuctionView
5. View class gets ViewModel from Application.Instance
6. On platforms without data binding, the view
subscribes itself to PropertyChanged on
ViewModel, for select (groups of) properties (it is
not necessary to bind to each individual property).
Also the commands of the views are invoked from code
in an event handler.
7. The viewmodel is updated by events from service and
commands from view. The view updates w data binding.
8. A command on a viewmodel can invoke the ContinueTo…
method on application … continue with step 3.
1
2
3
4
5 6
78
2
ViewModel
• Properties
• Commands
• INotifyPropertyChanged, INoti
fyCollectionChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Navigator
• Navigate to view
implementation
Entry
Point
Runtime flow: Application starts with AuctionView, user
places bid and navigates to CheckoutView.
1. Entrypoint is called, creates Navigator and
Application instances.
2. Application ctor creates ServiceAgent and
AuctionViewModel + ProductsViewModel
3. Entry Point calls
MyApplication.Instance.NavigateToAuctionView()
4. Navigator calls platform-specific navigate to
AuctionView
5. View class gets ViewModel from Application.Instance
6. On platforms without data binding, the view
subscribes itself to PropertyChanged on
ViewModel, for select (groups of) properties (it is
not necessary to bind to each individual property).
Also the commands of the views are invoked from code
in an event handler.
7. The viewmodel is updated by events from service and
commands from view. The view updates w data binding.
8. A command on a viewmodel can invoke the ContinueTo…
method on application … continue with step 3.
1
2
3
4
5 6
78
2
ViewModel
• Properties
• Commands
• INotifyPropertyChanged,
INotifyCollectionChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Navigator
• Navigate to view
implementation
Entry
Point
Runtime flow: Application starts with AuctionView, user
places bid and navigates to CheckoutView.
1. Entrypoint is called, creates Navigator and
Application instances.
2. Application ctor creates ServiceAgent and
AuctionViewModel + ProductsViewModel
3. Entry Point calls
MyApplication.Instance.NavigateToAuctionView()
4. Navigator calls platform-specific navigate to
AuctionView
5. View class gets ViewModel from Application.Instance
6. On platforms without data binding, the view
subscribes itself to PropertyChanged on
ViewModel, for select (groups of) properties (it is
not necessary to bind to each individual property).
Also the commands of the views are invoked from code
in an event handler.
7. The viewmodel is updated by events from service and
commands from view. The view updates w data binding.
8. A command on a viewmodel can invoke the ContinueTo…
method on application … continue with step 3.
1
2
3
4
5 6
78
2
ViewModel
• Properties
• Commands
• INotifyPropertyChanged, INoti
fyCollectionChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Navigator
• Navigate to view
implementation
Entry
Point
Runtime flow: Application starts with AuctionView, user
places bid and navigates to CheckoutView.
1. Entrypoint is called, creates Navigator and
Application instances.
2. Application ctor creates ServiceAgent and
AuctionViewModel + ProductsViewModel
3. Entry Point calls
MyApplication.Instance.NavigateToAuctionView()
4. Navigator calls platform-specific navigate to
AuctionView
5. View class gets ViewModel from Application.Instance
6. On platforms without data binding, the view
subscribes itself to PropertyChanged on
ViewModel, for select (groups of) properties (it is
not necessary to bind to each individual property).
Also the commands of the views are invoked from code
in an event handler.
7. The viewmodel is updated by events from service and
commands from view. The view updates w data binding.
8. A command on a viewmodel can invoke the ContinueTo…
method on application … continue with step 3.
1
2
3
4
5 6
78
2
ViewModel
• Properties
• Commands
• INotifyPropertyChanged, INoti
fyCollectionChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Navigator
• Navigate to view
implementation
Entry
Point
Runtime flow: Application starts with AuctionView, user
places bid and navigates to CheckoutView.
1. Entrypoint is called, creates Navigator and
Application instances.
2. Application ctor creates ServiceAgent and
AuctionViewModel + ProductsViewModel
3. Entry Point calls
MyApplication.Instance.NavigateToAuctionView()
4. Navigator calls platform-specific navigate to
AuctionView
5. View class gets ViewModel from Application.Instance
6. On platforms without data binding, the view
subscribes itself to PropertyChanged on
ViewModel, for select (groups of) properties (it is
not necessary to bind to each individual property).
Also the commands of the views are invoked from code
in an event handler.
7. The viewmodel is updated by events from service and
commands from view. The view updates w data binding.
8. A command on a viewmodel can invoke the ContinueTo…
method on application … continue with step 3.
1
2
3
4
5 6
78
2
ViewModel
• Properties
• Commands
• INotifyPropertyChanged, INoti
fyCollectionChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Navigator
• Navigate to view
implementation
Entry
Point
Runtime flow: Application starts with AuctionView, user
places bid and navigates to CheckoutView.
1. Entrypoint is called, creates Navigator and
Application instances.
2. Application ctor creates ServiceAgent and
AuctionViewModel + ProductsViewModel
3. Entry Point calls
MyApplication.Instance.NavigateToAuctionView()
4. Navigator calls platform-specific navigate to
AuctionView
5. View class gets ViewModel from Application.Instance
6. On platforms without data binding, the view
subscribes itself to PropertyChanged on ViewModel,
for select (groups of) properties (it is not
necessary to bind to each individual property). Also
the commands of the views are invoked from code in an
event handler.
7. The viewmodel is updated by events from service and
commands from view. The view updates w data binding.
8. A command on a viewmodel can invoke the ContinueTo…
method on application … continue with step 3.
1
2
3
4
5 6
78
2
ViewModel
• Properties
• Commands
• INotifyPropertyChanged, INoti
fyCollectionChanged
Model
• Entities (POCO)
ServiceAgent
• Service Entities
• Service Events
• Service Methods
Application
• ViewModels instance
• Navigation context
• Navigation transitions
View
• Markup
• Data binding code
(if not supported in markup)
• UI Manipulation Code
Navigator
• Navigate to view
implementation
Entry
Point
Runtime flow: Application starts with AuctionView, user
places bid and navigates to CheckoutView.
1. Entrypoint is called, creates Navigator and
Application instances.
2. Application ctor creates ServiceAgent and
AuctionViewModel + ProductsViewModel
3. Entry Point calls
MyApplication.Instance.NavigateToAuctionView()
4. Navigator calls platform-specific navigate to
AuctionView
5. View class gets ViewModel from Application.Instance
6. On platforms without data binding, the view
subscribes itself to PropertyChanged on
ViewModel, for select (groups of) properties (it is
not necessary to bind to each individual property).
Also the commands of the views are invoked from code
in an event handler.
7. The viewmodel is updated by events from service and
commands from view. The view updates w data binding.
8. A command on a viewmodel can invoke the ContinueTo…
method on application … continue with step 3.
1
2
3
4
5 6
78
2
http://nuget.org/packages/mvvmquickcross
http://github.com/MacawNL/MvvmQuickCross/
http://xamarin.com/
http://propertycross.com/
http://twitter.com/vincenth_net http://vincenth.net

Contenu connexe

Tendances

Writing Gadgets with the WSO2 Gadget Server
Writing Gadgets with the WSO2 Gadget ServerWriting Gadgets with the WSO2 Gadget Server
Writing Gadgets with the WSO2 Gadget Server
WSO2
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
Wei Ru
 

Tendances (20)

AngularJS
AngularJSAngularJS
AngularJS
 
jQuery
jQueryjQuery
jQuery
 
Angular js
Angular jsAngular js
Angular js
 
Building a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web ServicesBuilding a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web Services
 
준비하세요 Angular js 2.0
준비하세요 Angular js 2.0준비하세요 Angular js 2.0
준비하세요 Angular js 2.0
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish Minutes
 
Writing Gadgets with the WSO2 Gadget Server
Writing Gadgets with the WSO2 Gadget ServerWriting Gadgets with the WSO2 Gadget Server
Writing Gadgets with the WSO2 Gadget Server
 
Angular js
Angular jsAngular js
Angular js
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
Databinding and Performance-Tuning in Angular 2
Databinding and Performance-Tuning in Angular 2Databinding and Performance-Tuning in Angular 2
Databinding and Performance-Tuning in Angular 2
 
Creating lightweight JS Apps w/ Web Components and lit-html
Creating lightweight JS Apps w/ Web Components and lit-htmlCreating lightweight JS Apps w/ Web Components and lit-html
Creating lightweight JS Apps w/ Web Components and lit-html
 
WOdka
WOdkaWOdka
WOdka
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법
 
Android DevConference - Android Clean Architecture
Android DevConference - Android Clean ArchitectureAndroid DevConference - Android Clean Architecture
Android DevConference - Android Clean Architecture
 
MVVM with SwiftUI and Combine
MVVM with SwiftUI and CombineMVVM with SwiftUI and Combine
MVVM with SwiftUI and Combine
 
Wicket Intro
Wicket IntroWicket Intro
Wicket Intro
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
 
AngularJS Framework
AngularJS FrameworkAngularJS Framework
AngularJS Framework
 

Similaire à MvvmQuickCross for Windows Phone

Hanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvcHanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvc
denemedeniz
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
Yared Ayalew
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockout
Andoni Arroyo
 

Similaire à MvvmQuickCross for Windows Phone (20)

ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015
 
Hanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvcHanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvc
 
MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming model
 
Asp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design PatternAsp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design Pattern
 
Asp.net mvc 6 with sql server 2014
Asp.net mvc 6 with sql server 2014Asp.net mvc 6 with sql server 2014
Asp.net mvc 6 with sql server 2014
 
The MEAN stack
The MEAN stack The MEAN stack
The MEAN stack
 
Mini-Training: AngularJS
Mini-Training: AngularJSMini-Training: AngularJS
Mini-Training: AngularJS
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockout
 
Do iOS Presentation - Mobile app architectures
Do iOS Presentation - Mobile app architecturesDo iOS Presentation - Mobile app architectures
Do iOS Presentation - Mobile app architectures
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Pattern
 
Angular patterns
Angular patternsAngular patterns
Angular patterns
 
Dmytro Zaitsev Viper: make your mvp cleaner
Dmytro Zaitsev Viper: make your mvp cleanerDmytro Zaitsev Viper: make your mvp cleaner
Dmytro Zaitsev Viper: make your mvp cleaner
 
SE2016 Android Dmytro Zaitsev "Viper make your MVP cleaner"
SE2016 Android Dmytro Zaitsev "Viper  make your MVP cleaner"SE2016 Android Dmytro Zaitsev "Viper  make your MVP cleaner"
SE2016 Android Dmytro Zaitsev "Viper make your MVP cleaner"
 
Asp.Net MVC 5 in Arabic
Asp.Net MVC 5 in ArabicAsp.Net MVC 5 in Arabic
Asp.Net MVC 5 in Arabic
 
Angular
AngularAngular
Angular
 
ASP .net MVC
ASP .net MVCASP .net MVC
ASP .net MVC
 
Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018
 
MVC Puree - Approaches to MVC with Umbraco
MVC Puree - Approaches to MVC with UmbracoMVC Puree - Approaches to MVC with Umbraco
MVC Puree - Approaches to MVC with Umbraco
 
Sexy Architecting. VIPER: MVP on steroids
Sexy Architecting. VIPER: MVP on steroidsSexy Architecting. VIPER: MVP on steroids
Sexy Architecting. VIPER: MVP on steroids
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

MvvmQuickCross for Windows Phone

  • 1.
  • 4. ViewModel • Properties • Commands • INotifyPropertyChanged Model • Entities (POCO) View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code
  • 5. ViewModel • Properties • Commands • INotifyPropertyChanged Model • Entities (POCO) Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Navigator • Navigate to view implementation Entry Point
  • 6. ViewModel • Properties • Commands • INotifyPropertyChanged Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Navigator • Navigate to view implementation Entry Point
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. Main View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Main ViewModel • Properties • Commands • INotifyPropertyChanged SubB ViewModel • Properties • Commands • INotifyPropertyChanged SubA ViewModel • Properties • Commands • INotifyPropertyChanged SubB View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code SubA View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Composite ViewModels are also possible: class MainViewModel : ViewModelBase { List<ItemViewModel> MyItems /* Data-Bindable property }
  • 15.
  • 16.
  • 17. ViewModel • Properties • Commands • INotifyPropertyChanged public int Count /* One-way data-bindable property generated with propdb1 snippet … public string MyProperty /* Two-way data-bindable property generated with propdb2 snippet … public string MyProperty2 /* Two-way data-bindable property that calls custom code in OnMyProperty2Changed() from setter, generated with propdb2c snippet … /* One-way data-bindable property generated with propdbcol snippet… public ObservableCollection<string> MyCollection public bool MyCollectionHasItems protected void UpdateMyCollectionHasItems()
  • 18. ViewModel • Properties • Commands • INotifyPropertyChanged public RelayCommand DoSomethingCommand /* Data-bindable command that calls DoSomething(), generated with cmd snippet … private void DoSomething() { // TODO: Implement DoSomething() throw new NotImplementedException(); } public RelayCommand EditItemCommand /* Data-bindable command with parameter that calls EditItem(), generated with cmdp snippet … private void EditItem(object parameter) { var item = (Item)parameter; // TODO: Implement EditItem() throw new NotImplementedException(); }
  • 19. ViewModel • Properties • Commands • INotifyPropertyChanged // Design-time data support #if DEBUG namespace MyApp.ViewModels.Design { public class MyModelDesign : MyViewModel { public MyModelDesign() { // TODO: Initialize the view model with hardcoded design-time data } } } #endif Note: Design-data can initially also be used at runtime for fast application prototyping, before any services or models are implemented.
  • 20. ViewModel • Properties • Commands • INotifyPropertyChanged public abstract class ViewModelBase : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; protected virtual void RaisePropertyChanged( string propertyName) { … } } public class RelayCommand : ICommand { public RelayCommand(Action handler, … public RelayCommand(Action<object> handler, … public bool IsEnabled { … } }
  • 21. ViewModel • Properties • Commands • INotifyPropertyChanged View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code <phone:PhoneApplicationPage xmlns:vm= "clr-namespace:MyApp.Shared.ViewModels.Design; assembly=MyApp.Shared.wp" d:DataContext="{d:DesignInstance Type=vm:MyViewModelDesign, IsDesignTimeCreatable=True }" <TextBox Text="{Binding Title, Mode=TwoWay}" … </phone:PhoneApplicationPage> public partial class MyView : PhoneApplicationPage { public MyView() { InitializeComponent(); DataContext = MyApplication.Instance.MyViewModel; } }
  • 22. ViewModel • Properties • Commands • INotifyPropertyChanged Model • Entities (POCO) View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code public class ClientLotUpdate { public decimal CurrentPrice { get; set; } public int ProgressRemaining { get; set; } public RemainingTime TimeRemaining { get; set; } public ClientLotUpdate() { TimeRemaining = new RemainingTime(); } }
  • 23. ViewModel • Properties • Commands • INotifyPropertyChanged ServiceAgent • Service Entities • Service Events • Service Methods View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code public class ClientLotUpdate { public decimal CurrentPrice { get; set; } public int ProgressRemaining { get; set; } public RemainingTime TimeRemaining { get; set; } public ClientLotUpdate() { TimeRemaining = new RemainingTime(); } } Note that in simple cases service entities defined in the service contract can be used directly as the ‘model’.
  • 24. ViewModel • Properties • Commands • INotifyPropertyChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code public class LotUpdatedEventArgs : EventArgs { public ClientLotUpdate clientLotUpdate { get; set; } } public event EventHandler<LotUpdatedEventArgs> ActiveLotUpdated;
  • 25. ViewModel • Properties • Commands • INotifyPropertyChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code public class PlaceBidRequest { public int LotId { get; set; } public decimal Price { get; set; } } public Task RaisePlaceBidAsync(PlaceBidRequest placeBidRequest) { return _hubProxy.Invoke( "PlaceBid", new object[] { placeBidRequest }); }
  • 26. ViewModel • Properties • Commands • INotifyPropertyChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code public class AuctionApplication { void ContinueToAuction() void ContinueToCheckout(Basket basket) void ContinueToOrderConfirmed() void ContinueToProductList() void ContinueToProductPage(ClientLot product) void UserWantsToSignIn() bool IsUserLoggedIn() … } The ViewModel only uses the application to initiate navigation and to obtain relevant application state. ViewModels do not reference or modify other viewmodels. Exception: contained view models; e.g. a collection of ItemViewModel. ViewModels can pass parameters to the application, which in turn can use those to initialize other view models.
  • 27. ViewModel • Properties • Commands • INotifyPropertyChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code public abstract class ApplicationBase { public static Task RunOnUIThread(Action action) public object CurrentNavigationContext { get; set; } } class MyApplication : ApplicationBase { public static MyApplication Instance { get … } public MyViewModel MyViewModel { get; private set; } public void ContinueToItem(Item item = null) { if (MyViewModel == null) MyViewModel = new MyViewModel(_itemService); MyViewModel.Initialize(item); RunOnUIThread(() => _navigator.NavigateToMyView( CurrentNavigationContext)); } } Application initializes viewmodel and then calls navigator for platform-specific view navigation.
  • 28. ViewModel • Properties • Commands • INotifyPropertyChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Navigator • Navigate to view implementation public interface IMyAppNavigator { void NavigateToMyView(object navigationContext); void NavigateToOtherView(object navigationContext); } The navigator implementation is platform specific – it knows what type of object navigationContext is.
  • 29. ViewModel • Properties • Commands • INotifyPropertyChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Navigator • Navigate to view implementation Entry Point public partial class App : Application { public static MyApplication EnsureMyApplication( Frame navigationContext) { return MyApplication.Instance ?? new MyApplication(new MyNavigator(), navigationContext); } void Application_Launching(…) { EnsureMyApplication(RootFrame).ContinueToItemList( skipNavigation: true); } void Application_Activated(…) { EnsureMyApplication(RootFrame); } } The entry point is platform specific (navigationContext, here a WP Frame) and creates platform specific service instances, such as the Navigator.
  • 30. ViewModel • Properties • Commands • INotifyPropertyChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Navigator • Navigate to view implementation Entry Point class MyNavigator : IMyNavigator { void Navigate(object navigationContext, string uri) { ((Frame)navigationContext).Navigate( new Uri(uri, UriKind.Relative)); } void NavigateToMyView(object navigationContext) { Navigate(navigationContext, "/MyView.xaml"); } … } The navigator is platform specific (navigationContext, here a WP Frame).
  • 31. ViewModel • Properties • Commands • INotifyPropertyChanged, INoti fyCollectionChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Navigator • Navigate to view implementation Entry Point Runtime flow: Application starts with AuctionView, user places bid and navigates to CheckoutView. 1. Entrypoint is called, creates Navigator and Application instances. 2. Application ctor creates ServiceAgent and AuctionViewModel + ProductsViewModel 3. Entry Point calls MyApplication.Instance.NavigateToAuctionView() 4. Navigator calls platform-specific navigate to AuctionView 5. View class gets ViewModel from Application.Instance 6. On platforms without data binding, the view subscribes itself to PropertyChanged on ViewModel, for select (groups of) properties (it is not necessary to bind to each individual property). Also the commands of the views are invoked from code in an event handler. 7. The viewmodel is updated by events from service and commands from view. The view updates w data binding. 8. A command on a viewmodel can invoke the ContinueTo… method on application … continue with step 3. 1 2 3 4 5 6 78 2
  • 32. ViewModel • Properties • Commands • INotifyPropertyChanged, INoti fyCollectionChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Navigator • Navigate to view implementation Entry Point Runtime flow: Application starts with AuctionView, user places bid and navigates to CheckoutView. 1. Entrypoint is called, creates Navigator and Application instances. 2. Application ctor creates ServiceAgent and AuctionViewModel + ProductsViewModel 3. Entry Point calls MyApplication.Instance.NavigateToAuctionView() 4. Navigator calls platform-specific navigate to AuctionView 5. View class gets ViewModel from Application.Instance 6. On platforms without data binding, the view subscribes itself to PropertyChanged on ViewModel, for select (groups of) properties (it is not necessary to bind to each individual property). Also the commands of the views are invoked from code in an event handler. 7. The viewmodel is updated by events from service and commands from view. The view updates w data binding. 8. A command on a viewmodel can invoke the ContinueTo… method on application … continue with step 3. 1 2 3 4 5 6 78 2
  • 33. ViewModel • Properties • Commands • INotifyPropertyChanged, INoti fyCollectionChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Navigator • Navigate to view implementation Entry Point Runtime flow: Application starts with AuctionView, user places bid and navigates to CheckoutView. 1. Entrypoint is called, creates Navigator and Application instances. 2. Application ctor creates ServiceAgent and AuctionViewModel + ProductsViewModel 3. Entry Point calls MyApplication.Instance.NavigateToAuctionView() 4. Navigator calls platform-specific navigate to AuctionView 5. View class gets ViewModel from Application.Instance 6. On platforms without data binding, the view subscribes itself to PropertyChanged on ViewModel, for select (groups of) properties (it is not necessary to bind to each individual property). Also the commands of the views are invoked from code in an event handler. 7. The viewmodel is updated by events from service and commands from view. The view updates w data binding. 8. A command on a viewmodel can invoke the ContinueTo… method on application … continue with step 3. 1 2 3 4 5 6 78 2
  • 34. ViewModel • Properties • Commands • INotifyPropertyChanged, INoti fyCollectionChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Navigator • Navigate to view implementation Entry Point Runtime flow: Application starts with AuctionView, user places bid and navigates to CheckoutView. 1. Entrypoint is called, creates Navigator and Application instances. 2. Application ctor creates ServiceAgent and AuctionViewModel + ProductsViewModel 3. Entry Point calls MyApplication.Instance.NavigateToAuctionView() 4. Navigator calls platform-specific navigate to AuctionView 5. View class gets ViewModel from Application.Instance 6. On platforms without data binding, the view subscribes itself to PropertyChanged on ViewModel, for select (groups of) properties (it is not necessary to bind to each individual property). Also the commands of the views are invoked from code in an event handler. 7. The viewmodel is updated by events from service and commands from view. The view updates w data binding. 8. A command on a viewmodel can invoke the ContinueTo… method on application … continue with step 3. 1 2 3 4 5 6 78 2
  • 35. ViewModel • Properties • Commands • INotifyPropertyChanged, INoti fyCollectionChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Navigator • Navigate to view implementation Entry Point Runtime flow: Application starts with AuctionView, user places bid and navigates to CheckoutView. 1. Entrypoint is called, creates Navigator and Application instances. 2. Application ctor creates ServiceAgent and AuctionViewModel + ProductsViewModel 3. Entry Point calls MyApplication.Instance.NavigateToAuctionView() 4. Navigator calls platform-specific navigate to AuctionView 5. View class gets ViewModel from Application.Instance 6. On platforms without data binding, the view subscribes itself to PropertyChanged on ViewModel, for select (groups of) properties (it is not necessary to bind to each individual property). Also the commands of the views are invoked from code in an event handler. 7. The viewmodel is updated by events from service and commands from view. The view updates w data binding. 8. A command on a viewmodel can invoke the ContinueTo… method on application … continue with step 3. 1 2 3 4 5 6 78 2
  • 36. ViewModel • Properties • Commands • INotifyPropertyChanged, INotifyCollectionChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Navigator • Navigate to view implementation Entry Point Runtime flow: Application starts with AuctionView, user places bid and navigates to CheckoutView. 1. Entrypoint is called, creates Navigator and Application instances. 2. Application ctor creates ServiceAgent and AuctionViewModel + ProductsViewModel 3. Entry Point calls MyApplication.Instance.NavigateToAuctionView() 4. Navigator calls platform-specific navigate to AuctionView 5. View class gets ViewModel from Application.Instance 6. On platforms without data binding, the view subscribes itself to PropertyChanged on ViewModel, for select (groups of) properties (it is not necessary to bind to each individual property). Also the commands of the views are invoked from code in an event handler. 7. The viewmodel is updated by events from service and commands from view. The view updates w data binding. 8. A command on a viewmodel can invoke the ContinueTo… method on application … continue with step 3. 1 2 3 4 5 6 78 2
  • 37. ViewModel • Properties • Commands • INotifyPropertyChanged, INoti fyCollectionChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Navigator • Navigate to view implementation Entry Point Runtime flow: Application starts with AuctionView, user places bid and navigates to CheckoutView. 1. Entrypoint is called, creates Navigator and Application instances. 2. Application ctor creates ServiceAgent and AuctionViewModel + ProductsViewModel 3. Entry Point calls MyApplication.Instance.NavigateToAuctionView() 4. Navigator calls platform-specific navigate to AuctionView 5. View class gets ViewModel from Application.Instance 6. On platforms without data binding, the view subscribes itself to PropertyChanged on ViewModel, for select (groups of) properties (it is not necessary to bind to each individual property). Also the commands of the views are invoked from code in an event handler. 7. The viewmodel is updated by events from service and commands from view. The view updates w data binding. 8. A command on a viewmodel can invoke the ContinueTo… method on application … continue with step 3. 1 2 3 4 5 6 78 2
  • 38. ViewModel • Properties • Commands • INotifyPropertyChanged, INoti fyCollectionChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Navigator • Navigate to view implementation Entry Point Runtime flow: Application starts with AuctionView, user places bid and navigates to CheckoutView. 1. Entrypoint is called, creates Navigator and Application instances. 2. Application ctor creates ServiceAgent and AuctionViewModel + ProductsViewModel 3. Entry Point calls MyApplication.Instance.NavigateToAuctionView() 4. Navigator calls platform-specific navigate to AuctionView 5. View class gets ViewModel from Application.Instance 6. On platforms without data binding, the view subscribes itself to PropertyChanged on ViewModel, for select (groups of) properties (it is not necessary to bind to each individual property). Also the commands of the views are invoked from code in an event handler. 7. The viewmodel is updated by events from service and commands from view. The view updates w data binding. 8. A command on a viewmodel can invoke the ContinueTo… method on application … continue with step 3. 1 2 3 4 5 6 78 2
  • 39. ViewModel • Properties • Commands • INotifyPropertyChanged, INoti fyCollectionChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Navigator • Navigate to view implementation Entry Point Runtime flow: Application starts with AuctionView, user places bid and navigates to CheckoutView. 1. Entrypoint is called, creates Navigator and Application instances. 2. Application ctor creates ServiceAgent and AuctionViewModel + ProductsViewModel 3. Entry Point calls MyApplication.Instance.NavigateToAuctionView() 4. Navigator calls platform-specific navigate to AuctionView 5. View class gets ViewModel from Application.Instance 6. On platforms without data binding, the view subscribes itself to PropertyChanged on ViewModel, for select (groups of) properties (it is not necessary to bind to each individual property). Also the commands of the views are invoked from code in an event handler. 7. The viewmodel is updated by events from service and commands from view. The view updates w data binding. 8. A command on a viewmodel can invoke the ContinueTo… method on application … continue with step 3. 1 2 3 4 5 6 78 2
  • 40. ViewModel • Properties • Commands • INotifyPropertyChanged, INoti fyCollectionChanged Model • Entities (POCO) ServiceAgent • Service Entities • Service Events • Service Methods Application • ViewModels instance • Navigation context • Navigation transitions View • Markup • Data binding code (if not supported in markup) • UI Manipulation Code Navigator • Navigate to view implementation Entry Point Runtime flow: Application starts with AuctionView, user places bid and navigates to CheckoutView. 1. Entrypoint is called, creates Navigator and Application instances. 2. Application ctor creates ServiceAgent and AuctionViewModel + ProductsViewModel 3. Entry Point calls MyApplication.Instance.NavigateToAuctionView() 4. Navigator calls platform-specific navigate to AuctionView 5. View class gets ViewModel from Application.Instance 6. On platforms without data binding, the view subscribes itself to PropertyChanged on ViewModel, for select (groups of) properties (it is not necessary to bind to each individual property). Also the commands of the views are invoked from code in an event handler. 7. The viewmodel is updated by events from service and commands from view. The view updates w data binding. 8. A command on a viewmodel can invoke the ContinueTo… method on application … continue with step 3. 1 2 3 4 5 6 78 2
  • 41.
  • 42.
  • 43.
  • 44.