DataBinding in Windows Phone 7? - data-binding

Is there a guide somewhere showing an example of using ViewModels in a WP7 application?

You could check out Laurent Bugnion's EX14 - Understanding the MVVM Pattern - from Mix 10.
Laurent is the author of the popular MVVM Light Toolkit with support for WP7
Here's another couple of posts that may be of interest.
C#er : IMage: Model-View-ViewModel (MVVM) Explained
.NET by Example: Using MVVM Light to drive a Windows Phone 7 / Silverlight 4 map viewer
And this post gives you an overview of some of the MVVM Frameworks available.
JAPF » Blog Archive » Discover and compare existing MVVM frameworks !

While MVVM is really a great pattern (and will be even more important with Silverlight 5!), I would really consider twice if this is appropriate for your WP7 application.
Reasons:
No "Command" property for ButtonBase (it's SL3! Command was new in SL4). Therefore no easy use of Commanding-Pattern. You need to use RelayCommands, DelegateCommands or similar.
No Commanding-Pattern at all for items in the Application Bar (ApplicationBarButton or ApplicationBarMenueItem). Not even with RelayCommands, as the ApplicationBarItems do not derive from DependencyObject. :( (see http://blog.galasoft.ch/archive/2010/04/09/using-commands-with-applicationbarmenuitem-and-applicationbarbutton-in-windows-phone-7.aspx)
Dealing with Background-Threads, Dispatcher, etc. can be really cumbersome together with MVVM.
That doesn't mean, you shouldn't use MVVM!
But check out carefully, whether MVVM is a benefit for your project or an additional burden that makes depelopment over-complicated.
HTH

Related

ASP.NET MVC3 Single page design suggestion

I would like to create an UI for my app ( current I've an UI in WPF ) and I like the "Single Page Application" paradigma. I'm a little stuck on how to start implementing it: I don't mind about SEO, mine is an enterprise application. Do I need to use something like sammy.js, backbone.js and so on? I'm really new to Web GUI developement and I'm a little consfused: why can't just use jquery calls to drive my single page DOM? Is there some drawbacks about this strategy?
Checkout this series of blog posts by John Papa this could give you a jump start...
http://johnpapa.net/building-single-page-apps-with-knockout-jquery-and-web-api-ndash-the-story-begins
http://johnpapa.net/spapost2
http://johnpapa.net/spapost3
http://johnpapa.net/spapost4
http://johnpapa.net/spapost5
Hope this helps
First of all, you can do your single page application with jquery only. However, you will be writing a lot of plumbing code to handle interactions between the different parts of your UI. Which is not the most interesting part of the developmnent process, especially if frameworks do it nicely for you.
You should have a look at this question : https://stackoverflow.com/questions/5112899/knockout-js-vs-backbone-js-vs, and decide between knockout and backbone.
For implementing a simple master-detail UI (left column for listing items, right column for display, jquery popups for more details or editing), I chose knockout, and was not disappointed.
The learning curve is not as steep as backbone's, and coming from a WPF MVVM app it was easy to understand the development paradigm.
I chose ASP.NET MVC to serve the html templates using ViewResults, and after that everything went through JSON.
Knockout made this easy because of it's client side databinding capabilities. Then, when posting data back, MVC modelbinding made server side binding easy as well.
You could use just jQuery but it can soon become very hard to manage if not designed very carefully. Take a look at knockout.js which is mvvm it's great for managing state and reacting to events.
If you develop SPA then your best choice would be knockout.js+MVC+Ajax/jQuery

Is Microsoft pushing Spark or Razor for the future view engine for ASP.NET MVC?

I am planning to learn ASP.NET MVC soon. I wanted to get a clear picture of which view engine should I concentrate on, Spark or Razor? Which one is Microsoft putting more energy into?
Tony, I'm one of the developers on the ASP.NET MVC team. Here are some thoughts:
We developed Razor because we felt that the Aspx view engine had a number of shortcomings and we felt that we could do a lot better (and I do hope that people will agree that the result is a lot better). We would recommend Razor to anyone starting a new MVC 3 application. Anyone with an existing MVC 2 application and a heavy investment in the WebForms view engine will have to do their own cost/benefit analysis and decide if they want to switch.
Both view engines (Razor and Aspx) will continue to be supported (we are not planning on deprecating WebForms) and we will make sure that existing APIs as well as anything new that we add continue to work in both. That said, it might not always be possible to keep the feature set of each view engine at parity (for example, the #model keyword has no direct analouge in WebForms).
Spark is a 3rd-party component and it remains independent from Microsoft (regardless of the fact that its creator, Louis DeJardin is now employeed here). As such we are not currently contributing any code to it (since we've had our hands quite full with Razor). We are, however, fully committed to exposing all the necessary APIs and extensions points to support 3rd-party view engines. For example, in MVC 3 we have made improvements to the New Project and Add View dialogs to make it easier for the Spark (or any other view engine such as NHaml) developers or community to plug Spark into the built in MVC tooling experience.
Ultimately all options are valid (though in my personal opinion the Aspx view engine is slightly less valid :) and it's up to you to find the one that best fits your needs.
Spark has not been developed by Microsoft and I wouldn't say that they have/intend to put much energy on it. On the other hand Razor is Microsoft child and if you want an MS supported view engine go for it.
If you want to stay w/ Microsoft-supported view engines, then your options are Razor or WebForms. I prefer Razor of the two. Spark is arguably a better view engine than Razor is right now (depending on your sense of style), but as Darin pointed out it's not an MS product, so they're not putting energy into it that I'm aware of.
Razor is the best option if you want to minimize the amount of code in your view and if you like the syntax.
WebForms is good if you have a lot of experience with traditional ASP.NET and like the idea of having a code behind.
Spark is not supported or written by Microsoft.
For me, I use Razor as I like the syntax and I find my views a lot cleaner. Sure it's more verbose than haml, but at the same time it still is valid looking HTML and most web developers will pick it up naturally.

Is MVVM Light for Finanace product building with around 40 modules?

Just wondering should I be going on using MVVM light to buidl enterpside product? I read somewher MVVM is good for starting of small apps and Prism is good for composite apps. Can you please explain what does this mean? I just don't want to have dependency on huge framework like prism as sometimes it takes over the control from you leaving with you the option of following its development methodology. I think MVVM Light is simple and handy but jsut wanted to know whether it can be used in building composition based application or is there something out there where we can extend it to add composition to build modules of the product.
I hope my question is clear
First of all MVVM light is suitable for enterprise apps. However, it is a toolkit and not a full fetched framework, so if you need composition you will have to build it yourself. You could draw on MEF for support.
Prism on the other side is a fameworkthat builds on the MVVM model and the MEF. It has composition on board and you do not have to implement it on your own.
So it depends non then scope and the properties of your enterpise application which one you choose.
There are a couple of misconceptions in your question.
First of all none of the technologies you've mentioned are mutually exclusive. An appliction could be built using Prism, MEF and the MVVM Light toolkit.
Secondly, if you're developing a WPF application then you should be using the MVVM design pattern regardless of which technologies you decide to incorporate.
have dependency on huge framework like
prism
Prism actually has a relatively small footprint in an applications design. The features and components are essentially opt-in. Use the bits you need and ignore the stuff you dont need. Indeed, compared to the monstrosity that was SCSF, Prism is actually well designed.
There are arguably some overlapping goals of both Prism and MEF but this has been discussed here

What view engines for ASP.NET MVC are people finding better than the default?

It's been a year since this question and I'd like to know now - what view engines are people finding very good and why?
I believe the most active one is the Spark View Engine. It is very well documented including videos on certain topics. I have personally used the NHAML View Engine for a project and I liked it but the documentation is almost non-existent. I also think NHAML is not very active as far as adding features and fixing bugs.
I am planning on using the Spark View Engine in future projects.
NVelocity view engine is good if you're used to NVelocity syntax. The MVC Contrib project already contains MvcContrib.Castle.NVelocityViewFactory.
You can download from www.codeplex.com/mvccontrib
I read this out of a book I'm learining from, but I hope it helps since no one else responded.
I find NHAML a move in the positive direction and am using it in a pet project to see what its limitations are.
Spark may have it advantages, but I dislike how it is basically piggy-backs on existing syntax.
It looks uncomfortable to me, but that's just personal.
What I'm worried about is that new view engines possibly won't be able to profit from the forthcoming helpers in MVC2.

ASP.NET Application - Architecture and Class Diagrams

I am new to ASP.NET Development.
Could anyone please refer a document/tutorial/link which gives a sample code, architecture, class and sequence diagrams for 3 / 4 / n tier based simple ASP.NET application/example?
It would be of great help to me.
There is a lot of techniques / tool and various ways to do what you asked with .Net so I will give you some links for various tools:
N-Tier with:
ASP.Net 2.0
http://weblogs.asp.net/bsimser/archive/2006/08/13/3_2D00_tier-Architecture-wtih-ASP.NET-2.0.aspx
ASP.Net 3.5
http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=476
LINQ 2 SQL
http://weblogs.asp.net/dwahlin/archive/2008/02/28/building-an-n-layer-asp-net-application-with-linq-lambdas-and-stored-procedures.aspx
Dynamic Data
http://weblogs.asp.net/craigshoemaker/archive/2008/07/01/6-steps-to-n-tier-asp-net-dynamic-data.aspx
MVC
http://www.codeproject.com/KB/aspnet/aspnetmvc_bugtracker_v4.aspx
There is a lot of examples out there. Don't take the one's I have given you as the only one's but as a start for you. :-)
Happy Coding!
I made this sketch recently when explaining the difference between a typical classic Microsoft .ASP/SQL Server website architecture, and one that incorporates the newer Microsoft ASP.NET technology.
The box labeled “Front” at the top of the diagram represents a public website. Could be any size, large or small.
The “can” at the bottom represents a SQL Server database that is behind the scenes. The website user really doesn’t know or care that it is there, holding all the data for the website.
The middle area represents what can be done with ASP.NET technology. The boxes represent little “engines” of code that do specific things. One might process a credit card. One might add an item to a shopping cart. Another might list items on a page with a thumbnail image next to them. The list is endless.
The point here is that with ASP.NET, all these “engines” can be ready at anytime for use by themselves, or in combination with other “engines” to perform website tasks, and features. This lessens the amount of special code that needs to be placed inside the actual web pages represented by the top box. It is a far more efficient, and much faster technology, especially the more complex and complicated a website may be.
Just thought you might like to know that.
This may be the best collection you will find...
http://www.asp.net/get-started/
Look at sharpdevelop
It provides a solid foundation for creating asp.net mvc apps using best practices.
The project even provides Visual Studio templates.
Do yourself a favour and start with ASP.NET MVC and leave Webforms behind. Rob's Storefront tutorial is a great 3 tier example and the videos make it very easy to learn.

Resources