Mvvm mode of Silverlight

Source: Internet
Author: User

M is the model layer, which is actually the data service layer of the client. V is the page, that is, the view layer. VM is the model layer of the view, it can also be seen as a bridge layer between m and V.

We know that in database programming, especially in database programming in Delphi, the data-aware control must be impressive: the interface control only needs to set a data source and then set the fields to be bound to this control, this control establishes a connection with the dataset. When the dataset data changes, it is immediately fed back to the interface control. If the value in the control changes (user input or modification ), it can also be automatically updated to the dataset.

The data binding method of the Silverlight page control is similar to that of the preceding data sensing control. Of course, Microsoft has made great improvements:
1) All UI controls can be aware of data (almost every control has a datacontext attribute, which is actually similar to datasource );
2) data sources are no longer limited to data sets. They can be any accessible objects (including objects or object sets) (as long as this property has accessible properties ).

The above feature can be called object awareness (an improvement of dataset awareness). The reason for this feature is that it is a key technology that can exist in the mvvm mode. For specific practices, refer to some Microsoft documents. It is impossible to decompile their DLL. Next we will continue to look at this mode:
VM is the data source of V. In this way, the Data Binding of V and the event binding of V are performed manually on the V background.CodeWriting is changed to setting the binding attribute in XAML. In this way, V and Vm become loosely coupled. The relationship between Vm and M is that m is the provider of VM data and services. Because Vm, V and m are no longer directly coupled. This facilitates the division of labor and cooperation between clients.

Generally, in mvvm, one VM can provide multiple V, that is, one VM can have multiple display methods. In this respect, mvvm has the same effect as the MVC mode.

 

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.