Showing posts with label Model View ViewModel. Show all posts
Showing posts with label Model View ViewModel. Show all posts

Friday, August 19, 2011

Forcing validation for required fields in Silverlight - CodeProject

Silverlight LogoImage via WikipediaIntroduction to Article

The common practice in Silverlight, when using MVVM, is to validate user data via the bound property setter in the view model. Although this works well for most circumstances, it doesn't work when the user doesn't make a change to data and instead clicks on a button. For example, imagine a form that prompts the user for his/her name, which must not be blank, and then click a Next button. If the user just clicks the Next button without typing anything in the Name field, the validation via the bound property setter is never executed.
One way to address this is to repeat the validation in the view model when the user clicks Next. The issue with this is how to display the error message to the user in a way that is consistent (e.g. shown in a ValidationSummary and red tool tip, with any other error).



Forcing validation for required fields in Silverlight - CodeProject
Enhanced by Zemanta

Saturday, April 16, 2011

NetworkView: A WPF custom control for visualizing and editing networks, graphs and flow-charts - CodeProject

Introduction to the article

I am going to assume that you already know C# and have at least a basic knowledge of using WPF and XAML. An understanding of MVVM, WPF styles, control templates and data-templates will also help, although I'll do my best to fill in some of the details along the way and provide links to learning resources.
Josh Smith's Guided Tour of WPF and Sacha Barber's WPF: A Beginner's Guide are a good place to start if you want a WPF primer. Christian Mosers WPF Tutorial.net is full of interesting snippets of WPF information and has some great diagrams that can help explain WPF concepts.
Josh Smith also has an article on MVVM and if you already know a bit of WPF and MVVM I can recommend reading Gary Hall's book, I just read it and found that it has helped progress my MVVM knowledge and experience.



NetworkView: A WPF custom control for visualizing and editing networks, graphs and flow-charts - CodeProject
Enhanced by Zemanta

Sunday, March 6, 2011

WPF/MVVM Quick Start Tutorial - CodeProject

Introduction to Article

Assuming that you have a decent understanding of C++ and a modest understanding of C#, getting started in WPF shouldn't be too difficult. I started looking at WPF 6 months ago, and after probably causing a spike in Google's searches, I finally started to understand and become productive with WPF (whether I've missed the boat on this one, is another story for another day).
As with learning any new technology, you get the benefit of hindsight. From my perspective, almost every tutorial on WPF I've come across is inadequate for one of several reasons:
  • the example is all in WPF
  • the example glosses over the key facts that would actually make your life easier.
  • the example tries to show off WPF's capabilities with lots of pointless effects that aren't helping you.
  • the example uses classes that have properties that appear far too similar to framework keywords and classes, and are therefore difficult to idenfity in the (XAML) code as being user defined (ListBox GroupStyle's Name is a complete headache for novices).
So to address this, I've written this based on what I would have liked to have found as the #1 hit on Google after typing 'WPF Tutorial'. This article may not be 100% correct, or even do things 'the one true way', but it will illustrate the main points that I wish I had found in one place 6 months ago.
I will quickly introduce some topics, then show an example that explains or demonstrates each point. Accordingly, I haven't really attempted to make the GUIs pretty, that's not the point of this article (see the bullet points above).
As this tutorial is quite long, I've elided quite a lot of code for brevity, so please download the attached zip file, and look at the examples (.Net 4.0/VS2010). Each example builds on the previous one.


WPF/MVVM Quick Start Tutorial - CodeProject
Enhanced by Zemanta

Tuesday, February 15, 2011

Data and Command Bindings for Silverlight MVVM Applications - CodeProject

Introduction to article

This article summarizes two utility classes used for data and command bindings in Silverlight MVVM applications and demonstrates how to use the two classes with a running example.


Data and Command Bindings for Silverlight MVVM Applications - CodeProject
Enhanced by Zemanta

Wednesday, February 9, 2011

How to Disable right click popup menu in a MVVM silverlight 4.0 application. - CodeProject

Introduction to Article

Recently in one of the projects I was working on, we had the need to disable the silverlight configuration dialog box which appears automatically when the user clicks anywhere on the silverlight application as shown below.


How to Disable right click popup menu in a MVVM silverlight 4.0 application. - CodeProject
Enhanced by Zemanta

Friday, January 14, 2011

Android Binding - Introduction - CodeProject

Image representing Android as depicted in Crun...Image via CrunchBaseIntroduction to Article

Android Binding is a new Open Source Framework for Android-Java providing xml layout view binding mechanism. It helsp development of Android Application by decoupling the View widgets and backend Activities. It is best work with MVP or MVVM patterns.


Android Binding - Introduction - CodeProject
Enhanced by Zemanta

Monday, October 4, 2010

Silverlight Unsaved Data Detection - CodeProject

Detect that a user has un-saved changes and popup a box that allows them to stop navigating away from the page (using ViewModel / MVVM)

Silverlight Unsaved Data Detection - CodeProject
Enhanced by Zemanta

Sunday, September 5, 2010

Simple Silverlight Configurator/Pivot (View Model/MVVM) - CodeProject

 Tool for creating an interface for displaying and interacting with data:

Live example:
The application allows your users to query a collection (over web services), using drop downs and sliders. The results appear in a animated display.
You may ask, why not just use Microsoft Pivot? The main reasons are:
  • This one uses View Model / MVVM so the user interface can be completely designed by a designer.
  • There is not a lot of code, you can adapt this for your own use quickly.
  • This does not focus on images. Microsoft Pivot is designed to display high quality images. However, you can adapt this to display images.
  • This is a smaller application and it loads faster.
  • This is designed to work with your data coming directly from a database.
If the above does not apply to you, you may wish to use Microsoft Pivot instead.


Simple Silverlight Configurator/Pivot (View Model/MVVM) - CodeProject
Enhanced by Zemanta