The first time I used mvvmlight, I got orz.

Source: Internet
Author: User

WPF is a pure novice. I used WPF once or twice as winform. At that time, I didn't know about WPF at all, so it was like WPF = winform's background code + XAML version of ASP. net

This preparation starts a WPF project, and the leaders hope thatCodeI tried to separate it as much as possible before I found this article "WPF 4 unleashed". Then I had a brief understanding of prism and mvvmlight and I was ready to start it ~~

It seems that the mvvmlight on stackoverflow is still very good. I am ready to use this. The first time I use the result, I will use orz. I will write some preliminary experiences for other WPF beginners in the group, please give me more advice.

■ Installation

When I tried to create an mvvmlight application, the Project template (projectfortemplate. csproj) could not be found.

The solution is to put mvvmlight under the directory (c: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ common7 \ ide \ projecttemplatescache \ CSHARP \ windows \ mvvm \ mvvmlight.wpf4.zip) where the error is reported. rename wpf4.csproj.-V-

By the way, I also downloaded the manually installed zip package. It seems that the file name is correct. I will try to install it manually next time.

Code snippets does not seem to have intelligent awareness like prop? I also found it from code snippets manager. Should I move it to Visual C # Under snippets \ CSHARP? I don't know... Help

■ Viewmodel Problems

What is the problem with generating such code?

// Remove one of the two CILS below
Throw New Notimplementedexception ();

// Update bindings, no broadcast
/// raisepropertychanged (useridpropertyname);

//Update bindings and broadcast change using galasoft. mvvmlight. Messenging
//Raisepropertychanged (useridpropertyname, oldvalue, value, true );

I have not yet understood what the so-called broadcast is for. Is it a bus-like design? However, from the perspective of API design, I always think that these two methods have an internal call relationship, so I was surprised when I found that both methods can be reloaded --

In addition, in order to write a property to get such a pile of code, it does not seem a headache to generate a region magic horse... I can't refer to the Shenma policywaver (the name seems to be longer? Don't remember ...) After compilation?

■ Messenger Problems

This is where I really want to talk!

There are more ways to publish Shenma messenger than imessenger! Although this is also true, the messengerinstance in viewmodelbase is of the imessenger type! In this case, isn't it forcing me to use messenger. Default! What is the use of messengerinstance!

Then the send method can also specify the target... In my example, a view is specified... In this way, how can viewmodel be separated from view! Dead

Finally, write such code for a navigation...

A command of a viewmodel

Messenger. Default. Send ("Xxxx","Navigationrequest");

A View

Messenger. Default. register < String > ( This , " Navigationrequest "
, Action =>
{
If (Action. Equals ( " Xxxx " ,
Stringcomparison. invariantcultureignorecase ))
{
_ Mainframe. navigationservice. navigate (
New Uri ( " /Views/dashboard. XAML " , Urikind. Relative ));
}
});

Use a string"Navigationrequest"Is token... In addition, you can specify that the send method of the token is not in imessenger...

 

Call. Here we are ~

 

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.