SlideShare a Scribd company logo
Braintree
http://www.nrumyantsev.com/




    
    
    





2
3









4
Model                View




            Controller




5
Model                  View

                           DataBinding


            Presentation
               Model
            (ViewModel)



6
7






8
<DataTemplate x:Key="MapTemplate">
           <my:Pushpin Location="{Binding Location}" />
</DataTemplate>

...

<my:Map Name="map1"
        Height="494"
        HorizontalAlignment="Left"
        Margin="20,6,0,0"
        VerticalAlignment="Top"
        Width="444"
        Center="{Binding MapCenter, Mode=TwoWay}"
        ZoomLevel="{Binding MapZoomLevel, Mode=TwoWay}">
        <my:MapItemsControl x:Name="ListOfItems"
                  ItemTemplate="{StaticResource MapTemplate}"
                  ItemsSource="{Binding LocationDataCollection}">
        </my:MapItemsControl>
 </my:Map>




  9


     



     <StackPanel Orientation="Horizontal" Height="22">
             <Label Width="50"> Options: </Label>
             <Button x:Name="Search" Width="100"
                     Command="{Binding SearchCommand}" >Search</Button>
     </StackPanel>




10
public class SearchCommand : ICommand
   {
       private ViewModel viewModel;

         public SearchCommand(ViewModel viewModelInstance)
         {
             viewModel = viewModelInstance;
         }

         #region ICommand Members
         public bool CanExecute(object parameter)
         {
             return true;
         }

         public event EventHandler CanExecuteChanged
         {
             add { CommandManager.RequerySuggested += value; }
             remove { CommandManager.RequerySuggested -= value; }
         }

         public void Execute(object parameter)
         {
             viewModel.Search();
         }
         #endregion
11   }









      http://unity.codeplex.com
12   




     IUnityContainer Container = new UnityContainer();

     if (ViewModelBase.IsInDesignModeStatic)
     {
             Container.RegisterType<IDataService,Design.DesignDataService>();
     }
     else
     {
             Container.RegisterType<IDataService, DataService>();
     }

     Container.RegisterType<MainViewModel>
             (new ContainerControlledLifetimeManager());

13
14
15





     
     
     




16




     <phone:PhoneApplicationPage
       x:Class="MvvmLiteRTM.MainPage"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
       xmlns:vm="clr-namespace:MvvmLiteRTM.ViewModel"
       DataContext="{Binding Main, Source={StaticResource Locator}}"
       shell:SystemTray.IsVisible="True“>




17





     <Button Content=“ZoomIn" Height="72" Name=“ZoomInButton">
        <i:Interaction.Triggers>
             <i:EventTrigger EventName="Click">
               <cmd:EventToCommand Command="{Binding ZoomInCommand}"/>
             </i:EventTrigger>
        </i:Interaction.Triggers>
     </Button>




18






         RelayCommand ZoomOutCommand = new RelayCommand(
                 () =>
                 {
                         MapZoomLevel--;
                 }
         );




    19
View


       View
                          Messages       ViewModel


     ViewModel
                                       View

                 Messages
                 + callback

                                     ViewModel

20





         private void SendMessageWithCallback()
         {
            Messenger.Default.Send(new NotificationMessageAction<string>(
                         "Hello, call me back",
                         SendMessageCallback));
         }

         private void SendMessageCallback(string message)
         {
                 ...
         }

    21
private NotificationMessageAction<string> _lastMessage;

     public void MessageRecipient()
     {
             Messenger.Default.Register<NotificationMessageAction<string>>(
                     this,
                     m =>
                     {
                         MessageTextBox.Text = m.Notification;
                         _lastMessage = m;

                          // Execute callback with parameter
                          _lastMessage.Execute(MessageTextBox.Text);
                    });
     }



22

     http://ultralightmvvm.codeplex.com/

     http://mvvmlight.codeplex.com/

     http://catel.codeplex.com/

     http://caliburnmicro.codeplex.com/


23
     http://www.japf.fr/silverlight/mvvm/index.html
24


     
     
     

     
     


     
     
25

     

     



     
     




26
View                   Feature




     View Model               IFeature




                  Injection




27








28
29

     









30


      http://create.msdn.com
      http://silverlight.codeplex.com/

      Model-View-ViewModel (MVVM) Explained
      WPF Apps With The Model-View-ViewModel Design Pattern - Josh
       Smith
      http://nrumyantsev.com/
      me@nrumyantsev.com


31

More Related Content

PDF
SISTEMA DE FACTURACION (Ejemplo desarrollado)
PDF
Visual Studio.Net - Sql Server
DOCX
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
PPTX
MVVM e Caliburn Micro for Windows Phone applications
PPTX
Présentation et bonnes pratiques du pattern MVVM - MIC Belgique
KEY
Grails UI Primer
PDF
Sistema de ventas
DOCX
VISUALIZAR REGISTROS EN UN JTABLE
SISTEMA DE FACTURACION (Ejemplo desarrollado)
Visual Studio.Net - Sql Server
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
MVVM e Caliburn Micro for Windows Phone applications
Présentation et bonnes pratiques du pattern MVVM - MIC Belgique
Grails UI Primer
Sistema de ventas
VISUALIZAR REGISTROS EN UN JTABLE

What's hot (20)

PDF
The Ring programming language version 1.8 book - Part 12 of 202
PDF
The Ring programming language version 1.9 book - Part 14 of 210
DOC
Quanlycanbo
PPTX
Magento Dependency Injection
DOCX
Calculadora
PDF
Awesome State Management for React and Other Virtual-Dom Libraries
PDF
Mobile Web 5.0
PDF
Magento2&amp;java script (2)
PDF
Elm: give it a try
PDF
Knockout.js Overview
PDF
Single page webapps & javascript-testing
PDF
Cycle.js: Functional and Reactive
PDF
jQuery secrets
PPTX
Final tagless and cats mtl
PDF
Aplikasi rawat-inap-vbnet
PDF
Coding website
PPTX
Everyday's JS
PPTX
Windows Azure 2/8 - Recursos básicos do Windows Azure
PDF
Command-Oriented Architecture
PDF
2018年のXamarinの概要と活用方法
The Ring programming language version 1.8 book - Part 12 of 202
The Ring programming language version 1.9 book - Part 14 of 210
Quanlycanbo
Magento Dependency Injection
Calculadora
Awesome State Management for React and Other Virtual-Dom Libraries
Mobile Web 5.0
Magento2&amp;java script (2)
Elm: give it a try
Knockout.js Overview
Single page webapps & javascript-testing
Cycle.js: Functional and Reactive
jQuery secrets
Final tagless and cats mtl
Aplikasi rawat-inap-vbnet
Coding website
Everyday's JS
Windows Azure 2/8 - Recursos básicos do Windows Azure
Command-Oriented Architecture
2018年のXamarinの概要と活用方法
Ad

Viewers also liked (18)

PPT
Palestra de Dado Schneider
PPTX
Digital Storytelling
PDF
analisis financiero
PPTX
Planificacion educativa
PPTX
Preparing the 4 h message for captiol hill
PDF
Sociedades humanas. ob
PDF
Show Photos
PPTX
Touring dc
PPT
Realmadrid
PPT
Southpark
PPT
Southpark
PPTX
Style Seeker App
PDF
Pze x4 p_en
PDF
Park model
PPTX
2012 collegiate facilitators & ylt
PPT
Chaperone webinar.pptx
PPTX
Adult orientation
PPTX
bio battery ppt
Palestra de Dado Schneider
Digital Storytelling
analisis financiero
Planificacion educativa
Preparing the 4 h message for captiol hill
Sociedades humanas. ob
Show Photos
Touring dc
Realmadrid
Southpark
Southpark
Style Seeker App
Pze x4 p_en
Park model
2012 collegiate facilitators & ylt
Chaperone webinar.pptx
Adult orientation
bio battery ppt
Ad

Similar to Применение шаблона проектирования MVVM при разработке архитектуры Windows Phone 7 приложений (20)

PPTX
Applied MVVM in Windows 8 apps: not your typical MVVM session!
PPTX
Advanced MVVM in Windows 8
PPTX
Windows Phone 7 Silverlight MVVM App the Test-Driven
PPTX
MvvmQuickCross for Windows Phone
PPTX
MVVM with WPF
 
PPTX
Windows Store app using XAML and C#: Enterprise Product Development
PDF
WPF - the future of GUI is near
PPTX
The Magic of WPF & MVVM
PPTX
Wi phug windows phone development from z to a
PPTX
Introduction to XAML and its features
PPTX
Understanding The MVVM Pattern (TechDays Belgium)
PPTX
Whats New for WPF in .NET 4.5
PPTX
Designing for Windows Phone 8
PPTX
Windows phone and azure
PPT
Developing application for Windows Phone 7 in TDD
PPTX
WPF For Beginners - Learn in 3 days
PDF
netmind - Primer Contacto con el Desarrollo de Aplicaciones para Windows 8
PPTX
Meetup - Getting Started with MVVM Light for WPF - 11 may 2019
PPT
Caliburn.micro jump start composite applications for WPF, Silverlight and WP7
KEY
What's new in Silverlight 5
Applied MVVM in Windows 8 apps: not your typical MVVM session!
Advanced MVVM in Windows 8
Windows Phone 7 Silverlight MVVM App the Test-Driven
MvvmQuickCross for Windows Phone
MVVM with WPF
 
Windows Store app using XAML and C#: Enterprise Product Development
WPF - the future of GUI is near
The Magic of WPF & MVVM
Wi phug windows phone development from z to a
Introduction to XAML and its features
Understanding The MVVM Pattern (TechDays Belgium)
Whats New for WPF in .NET 4.5
Designing for Windows Phone 8
Windows phone and azure
Developing application for Windows Phone 7 in TDD
WPF For Beginners - Learn in 3 days
netmind - Primer Contacto con el Desarrollo de Aplicaciones para Windows 8
Meetup - Getting Started with MVVM Light for WPF - 11 may 2019
Caliburn.micro jump start composite applications for WPF, Silverlight and WP7
What's new in Silverlight 5

Recently uploaded (20)

PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
1. Introduction to Computer Programming.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
August Patch Tuesday
PPTX
TLE Review Electricity (Electricity).pptx
PPTX
Tartificialntelligence_presentation.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
project resource management chapter-09.pdf
PPTX
A Presentation on Touch Screen Technology
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Mushroom cultivation and it's methods.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Heart disease approach using modified random forest and particle swarm optimi...
DP Operators-handbook-extract for the Mautical Institute
gpt5_lecture_notes_comprehensive_20250812015547.pdf
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Assigned Numbers - 2025 - Bluetooth® Document
1. Introduction to Computer Programming.pptx
MIND Revenue Release Quarter 2 2025 Press Release
August Patch Tuesday
TLE Review Electricity (Electricity).pptx
Tartificialntelligence_presentation.pptx
Unlocking AI with Model Context Protocol (MCP)
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
cloud_computing_Infrastucture_as_cloud_p
Zenith AI: Advanced Artificial Intelligence
project resource management chapter-09.pdf
A Presentation on Touch Screen Technology
A novel scalable deep ensemble learning framework for big data classification...
Mushroom cultivation and it's methods.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...

Применение шаблона проектирования MVVM при разработке архитектуры Windows Phone 7 приложений

  • 2.          2
  • 3. 3
  • 5. Model View Controller 5
  • 6. Model View DataBinding Presentation Model (ViewModel) 6
  • 7. 7
  • 9. <DataTemplate x:Key="MapTemplate"> <my:Pushpin Location="{Binding Location}" /> </DataTemplate> ... <my:Map Name="map1" Height="494" HorizontalAlignment="Left" Margin="20,6,0,0" VerticalAlignment="Top" Width="444" Center="{Binding MapCenter, Mode=TwoWay}" ZoomLevel="{Binding MapZoomLevel, Mode=TwoWay}"> <my:MapItemsControl x:Name="ListOfItems" ItemTemplate="{StaticResource MapTemplate}" ItemsSource="{Binding LocationDataCollection}"> </my:MapItemsControl> </my:Map> 9
  • 10.    <StackPanel Orientation="Horizontal" Height="22"> <Label Width="50"> Options: </Label> <Button x:Name="Search" Width="100" Command="{Binding SearchCommand}" >Search</Button> </StackPanel> 10
  • 11. public class SearchCommand : ICommand { private ViewModel viewModel; public SearchCommand(ViewModel viewModelInstance) { viewModel = viewModelInstance; } #region ICommand Members public bool CanExecute(object parameter) { return true; } public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } public void Execute(object parameter) { viewModel.Search(); } #endregion 11 }
  • 12.      http://unity.codeplex.com 12 
  • 13. IUnityContainer Container = new UnityContainer(); if (ViewModelBase.IsInDesignModeStatic) { Container.RegisterType<IDataService,Design.DesignDataService>(); } else { Container.RegisterType<IDataService, DataService>(); } Container.RegisterType<MainViewModel> (new ContainerControlledLifetimeManager()); 13
  • 14. 14
  • 15. 15
  • 16.       16
  • 17.   <phone:PhoneApplicationPage x:Class="MvvmLiteRTM.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:vm="clr-namespace:MvvmLiteRTM.ViewModel" DataContext="{Binding Main, Source={StaticResource Locator}}" shell:SystemTray.IsVisible="True“> 17
  • 18.   <Button Content=“ZoomIn" Height="72" Name=“ZoomInButton"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <cmd:EventToCommand Command="{Binding ZoomInCommand}"/> </i:EventTrigger> </i:Interaction.Triggers> </Button> 18
  • 19.   RelayCommand ZoomOutCommand = new RelayCommand( () => { MapZoomLevel--; } ); 19
  • 20. View View Messages ViewModel ViewModel View Messages + callback ViewModel 20
  • 21.   private void SendMessageWithCallback() { Messenger.Default.Send(new NotificationMessageAction<string>( "Hello, call me back", SendMessageCallback)); } private void SendMessageCallback(string message) { ... } 21
  • 22. private NotificationMessageAction<string> _lastMessage; public void MessageRecipient() { Messenger.Default.Register<NotificationMessageAction<string>>( this, m => { MessageTextBox.Text = m.Notification; _lastMessage = m; // Execute callback with parameter _lastMessage.Execute(MessageTextBox.Text); }); } 22
  • 23. http://ultralightmvvm.codeplex.com/  http://mvvmlight.codeplex.com/  http://catel.codeplex.com/  http://caliburnmicro.codeplex.com/  23 http://www.japf.fr/silverlight/mvvm/index.html
  • 24. 24
  • 25.          25
  • 26.      26
  • 27. View Feature View Model IFeature Injection 27
  • 29. 29
  • 30.       30
  • 31.    http://create.msdn.com  http://silverlight.codeplex.com/   Model-View-ViewModel (MVVM) Explained  WPF Apps With The Model-View-ViewModel Design Pattern - Josh Smith  http://nrumyantsev.com/  me@nrumyantsev.com 31

Editor's Notes

  • #6: -Does not have a presenter, has a controller-Request first comes to controller, binds the model with the view-Logic is stored in controller
  • #7: -State and Logic stored in Presenter-Presenter is an abstraction of view, Presenter unaware of view-View is aware of Presenter, however isolated from Model
  • #8: -State and Logic stored in Presenter-Presenter is an abstraction of view, Presenter unaware of view-View is aware of Presenter, however isolated from Model-Uses WPF and Silverlight bindings-A very loose coupling between view and viewmodel, very easy to write unit tests-Growing in popularity (several toolkits MVVM Light, Prism, Caliburn)-Used internally at Microsoft during Expression Blend creation
  • #12: -CanExecute determines if the command can be invoked on the current command target-Execute determines the command action to be performed-CanExecuteChanged event is raised when the command manager detects a change in the command source
  • #19: -Uses the System.Windows.Interactivity namespace
  • #20: -Avoid having to write separate class for commands, and implementing Icommand-lamba expression as an action
  • #21: -allows you to send messages between view models-possible to open up filtered channels (to target types/interfaces)
  • #22: -the sender sends a string message with a parameter of type NotificationMessageAction&lt;string&gt;-the callback parameter is a string
  • #23: -The recipient registers to receive a message of type NotificationMessageAction-The Notification property of the NotificationMessageAction type contains the string message-The recipient executes the sender’s callback with a string parameter
  • #31: -CheckBeginInvokeOnUI excepts Action parameter-Also contains UIThreadDispatrcher property in case you need to do other work on the UI thread.