Coder Social home page Coder Social logo

interview_mvvm-demo's Introduction

MVVM 範例

簡介

本範例使用 MVVM pattern,在 C# 中建立一個簡單的 WPF app。 該 app 展示了如何在不同的 View 顯示設備參數,以及如何使用 data binding 來保持 View 和 Model 之間的資料同步。

Tech Stack

  • C# (.NET 6)
  • WPF (Windows Presentation Foundation)
  • MVVM 架構

資料流

  1. MainWindow 建立一個 ObservableCollection 作為資料來源 (Model)。
  2. MainWindow 將 Model 傳遞給 TableViewViewModel 和 BottomViewViewModel。
  3. TableViewViewModel 將資料來源 binding 到 DataGrid 以在表格中顯示參數。
  4. BottomViewViewModel 將資料來源 (Baud Rate 參數) 轉換為其他格式。
  5. 當 Baud Rate 參數在上面的表格被修改時,TableViewViewModel 修改 Model 的內容。
  6. Model 會告知 BottomViewViewModel 內容有更新。
  7. BottomViewViewModel 更新其 BaudRateRange 屬性,觸發 View 的更新。
                MainWindow
              /            \
             /              \
            /                \
         DataGrid         BaudRateRange
         /                     \
    TableViewViewModel    BottomViewViewModel
          \                     /
           \                   /
            \                 /
             \               /
              \             /
               \           /
                 Parameter

interview_mvvm-demo's People

Contributors

ukewea 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.