For a couple of weeks I'm reading (and开发者_如何学编程 experimenting) with silverlight and mvvm pattern. I've learned a lot about it and I think I understand the basics of the pattern and framework but still I have few questions about practical usage of mvvm pattern. I hope someone with bigger experience then me can help me :)
Here are my questions:
Let's say I have many TextBlocks in my View, should I put readonly properties in the ViewModel for every TextBlocks? Should I do that with every text that I have in View? I feel it as a bit overwhelming and I wouldn't do that.
What about localization? Using resources files is the the best we have? Or should it be translated throughout properties in ViewModel?
Is there any good logging framework for SL? or I shouldn't use any and only focus on logging web services?
I've found this link: MVVM-light + RIA Services best practices - but I can't find answers to all my questions.
Edited:
Thanks to Adam I've found nlog: http://nlog.codeplex.com/ but it's in beta. Does anyone know anything else?
#1 - NO, you would not normally put readonly properties in your VM just for your view to bind its textblocks to. Those text values are just part of the view, just like they would be for an MVP WinForms app, or an MVC Web App.
#3 - possible duplicate of Silverlight Logging framework and/or best practices
For #2 If you use silverlight business application, you already have full support for localization. Check this out Silverlight 4 + RIA Services - Ready for Business: Localizing Business Application and I would do it on XAML level instead of VM
I highly recommend the MVVM In The Box training from my colleague Karl Shifflett of Microsoft patterns & practices.
精彩评论