Is MVVM still the preferred way with WinRT/Xaml apps?

Is MVVM still the preferred way with WinRT/Xaml apps?

Old forum URL: forums.lhotka.net/forums/t/11460.aspx


TSF posted on Saturday, July 07, 2012

I'm slowly working my way through my first go at a Xaml-based WinRT app.  For the most part, I think I've correctly got the Bxf framework compiled and usable within the WinRT.

One of the things I'm seeing in the defalt code when creating a new page in the project is that it assumes you're going to wire up the data and manually bind it to the collection view source via code.  The comments provided in the LoadState method in the code-behind even speaks to that.  Is this the preferred route now?  Or is Microsoft just providing one possible way of doing it to get someone started?  Can I follow a normal MVVM path to hooking up the view and viewmodel?  Any differences that I need be aware of? 

One other quick question:  the page templates that are provided (like the "Items Page" template) all seem to use a static resource for a grid's ItemSource that assumes the elements are binding to properties like "Title," "SubTitle," etc.  Is this also just a MS-example?  Or are we supposed to force our objects' properties into this mold?

Thanks.

RockfordLhotka replied on Sunday, July 08, 2012

I don't know the answer to this question yet.

Thus far I have been using the Microsoft templates, viewmodel objects, and a little code-behind to handle things like navigation and setting each form's datacontext. Not "pure" MVVM by any means, but very workable.

I have been focused on getting CSLA itself working with async/await and WinRT, and haven't spent any real time thinking about UI framework issues.

I know the MVVM Light and Caliburn Micro projects have put effort into the UI issues, and I think there's already an MVVM Light for WinRT.

What I don't know is whether their approaches are compatible with Microsoft's item templates. I'd sure hate to lose the ability to use those templates, because they do a lot of the basic work necessary to get standard transitions and animations set up correctly.

TSF replied on Monday, July 09, 2012

Thanks for the info.  So in the way that you're currently doing it, do you have one main view/page with a content control, in which you inject the sub-views when navigating?  Or are you doing it like what their templates show, where each page is unto itself?

Copyright (c) Marimer LLC