The ViewModel of WPF

Source: Internet
Author: User

Before I write, I'm going to ask the company to write a client with WPF, I've played WinForm before, I didn't write a serious project with WPF, I took over the WPF project and started studying this stuff, MVVM, custom controls, and so on. Perhaps it was winfrom preconceived thought that led me to think that WPF could be developed in accordance with the winfrom pattern, ViewModel, not to provide data, but after I looked at it, I found that the MVVM pattern development of WPF was simply an artifact. Well, the nonsense is not much to say, the following starts today's topic.

  1. Initial knowledge of the MVVM pattern of WPF
    • Model: Entity object (do not make too many explanations.) )
    • View: The UI layout in WPF.
    • ViewModel: View model.
  2. The benefits of MVVM
    • Reduce the coupling between the view layer and the model layer.
    • Events can be bound in ViewModel. (When I first started contacting WPF, I wrote the event into the view's. cs file, and now I think it's really ...) )
    • /// <summary>        ///Command/// </summary>         PublicICommand Loadcommand {Get;Set; }  PublicLogoviewmodel () {Loadcommand=NewRelaycommand (Click); }        Private voidClick () {MessageBox.Show ("This is a pop-up box event"); }
    • The method of bidirectional binding (which automatically notifies the model that the data has changed after the data has changed) is used to monitor whether the data has changed, and when changes are made, they are notified where the data is used for their own modification.
  3. What MVVM is going to do.
    • Plain English says the most basic thing to do with the MVVM framework is data binding and command binding. Because a large number of events are generated in the page UI, you also need to bind the events to commands in MVVM.

Write here today, if the younger brother wrote a question, welcome you Daniel many correct me.

To be continued before the end ... will continue to update tomorrow.

The ViewModel of WPF

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.