Giter VIP home page Giter VIP logo

learnwpf's Introduction

LearnWpf

Projects to learn WPF and MVVM

NavigationTest

Navigation on single window with navigation bar to switch between mutltiple views

Based on https://www.youtube.com/watch?v=wFzmBZpjuAo

NavigationTest2

Reimplementation of NavigationTest using MVVM Community Toolkit

SharingData

Sharing live data between two views using singleton service

Based on https://www.youtube.com/watch?v=umRSp4qB6Tw

SharingData2

Reimplementation of SharingData using MVVM Community Toolkit

ThemesTest

Switching between light and dark themes

Based on https://www.youtube.com/watch?v=Zr-pLUt9yEw

MessageTest

Use messager pub-sub mechanism to send messages between viewmodels

Based on https://learn.microsoft.com/en-us/dotnet/communitytoolkit/mvvm/messenger

CloseableTest

Close window/view from viewmodel

Based on https://stackoverflow.com/questions/16172462/close-window-from-viewmodel

LearnWpf.PasswordBox

Use wpf LearnWpf.PasswordBox correctly with mvvm pattern

Based on https://stackoverflow.com/questions/1483892/how-to-bind-to-a-LearnWpf.PasswordBox-in-mvvm

LearnWpf.CustomerDemo

Wpf MVVM customer CRUD with EFCore

Based on https://www.pluralsight.com/courses/wpf-mvvm-in-depth

LearnWpf.ViewModelAsyncDataTest

Async load of data into viewmodel

Based on CommunityToolkit/MVVM-Samples#25

MVVM

Basic principles

  • Model stores data and provides functions to manipulate the data
  • Model does NOT reference ViewModel
  • Model does NOT reference View
  • ViewModel does NOT reference View
  • ViewModel exposes data to View via properties
  • ViewModel exposes change events to View via INotifyPropertyChanged interface
  • ViewModel provides functionality to View via commands
  • ViewModel does NOT directly manipulate data
  • ViewModel references Model
  • ViewModel manipulates data either through functions in Model or additional layer
  • View references ViewModel
  • View does NOT implement business logic
  • View may implement logic ONLY when its purely for UI behavior
  • View binds to properties in view model
  • View calls commands exposed in ViewModel
  • View is notified of updates in ViewModel via INotifyPropertyChanged event

Responsibilities

Responsibilities for Model, ViewModel and View

Model

  • Contains client data
  • Contains model object relationships
  • Contains computed properties
  • Raise change events - implements INotifyPropertyChanged
  • Performs validation - implements IDataErrorInfo
  • Raise validation error events - implements INotifyDataError

ViewModel

  • Exposes data to view for reading and writing
  • Handles interaction logic ** Calls to domain layer, data layer, services ** Navigation ** Logic for managing client state

View

  • Structure and layout of UI
  • Rules for Code behind ** Ideally no code behind (as little as possible) ** Any code that REQUIRES explicit references to UI elements can be put in code behind ** Ideally abstract functionality via interfaces -> see CloseableTest ** Handle controls that do not support MVVM pattern

View First

  • View is constructed first
  • ViewModel is constructed and set as DataContext on the View

ViewModel First

  • ViewModel is constructed first
  • View is constructed based on ViewModel in UI (DataTemplate)

Resources

Projects are based on several text and video tutorials

learnwpf's People

Contributors

redagito avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.