Silverlight - Using MVVM pattern with WCF RIA services
I have picked up enough XAML, and Silverlight to write some good code for Silverlight applications. I prefer to use the MVVM pattern in the presentation layer, WCF RIA services for the service layer, and Entity Framework Code First for the data access layer. Getting all of this to work well together is some sort of nightmare for beginners. Sadly, there are no reference implementations either.
Entity framework and RIA uses EntitySet<T> as the collection class. I am more comfortable with ObservableCollection<T> or PagedCollectionView<T>. Even, the MVVM reference implementation - PRISM uses the ObservableCollection<T>.
For data validations, I prefer the IDataErrorInfo interface. This is more preferrable to Data Annotations. With RIA Services, the Entity class is auto-generated. So, I am not sure where I can put in my validations.
Another key problem with using MVVM model for beginners is the navigation. The Silverlight Business Application template solves this problem with the NavigationService class. If you are not using the Silverlight navigation framework and prefer to use the best practices from the PRISM framework, then navigation could be a nightmare. Try putting a simple "Are you sure to delete?" confirmation messagebox using the MVVM pattern.
Overall, learning MVVM, RIA, EFCF and putting them to work together is not the most pleasant experience as a developer. I hope to write a mini-reference implementation soon (A simple CRUD interface in Silverlight using MVVM, RIA, and EFCF).
Category : Silverlight