After several nights of struggle, the mvvm transformation journey of dbfm7 finally came to an end. From ignorance of mvvm to the current half-solution of mvvm, this process has learned a lot.
Mvvm aims to separate development concerns, write background logic to the background, and design UI to the UI. However, it is not so easy to achieve this. For example, navigation, such as animations, are not so easy to control in viewmodel, or once controlled in the VM, the original intention of mvvm is damaged. The above two problems are handled by using the message mechanism of mvvm light. Although it seems decoupled, it is still not thorough enough. In particular, viewmodel notifies the view to operate the storyboard.CodeThe viewmodel is still focusing on The View. I didn't think of a better solution yet. I was thinking that when a bound property (image URI) changes, the view will automatically trigger an animation (flying on the right ), this is perfect. It may be feasible. Which of the following experts will give you some advice.
The current viewmodel is much more fresh than codebehind, and there is no business mixed with UI operations. Of course codebehind does not have a single line of code. Codebehind is a part of the view. Some UI copying operations that cannot be defined in XAML can be put here. In addition, mvvm light is really easy to use, making your mvvm development simple and elegant!
Download the latest code to codeplex: http://dbfm7.codeplex.com/SourceControl/list/changesets
I just finished the change and haven't tested it well. Bugs are inevitable. Please tell me if you find it.
The following is a record of the transformation process. We hope to help mvvm beginners.
Mvvm reconstruction record of WP7 client of Douban station using mvvm light for Data Binding
Mvvm reconstruction record of WP7 client of Douban station using mvvm light for event binding
Mvvm reconstruction record on WP7 client of Douban station using message of mvvm light for navigation
Using appbarutils to bind applicationbariconbutton (including iconuri)