Mariano Ravinale's Blog

Sharing Experiences

Archive for the ‘Windows Phone 7’ Category

Mvvm Light project template for Windows Phone 7 RTM

with 2 comments

Today I would like to share a project template ready to build great windows phone 7 applications using Mvvm Light, first of all this this project template is an update that I made from the current Mvvm Light project hosted on codeplex: my favorite toolkit to build Silverlight and Windows Phone 7 applications.

Besides to make it compatible for the current tools version, and support the Laurent Bugnion Project, I just added a very simple reactive extensions example, in order to make it ready to work with services in our model.

Download the file: MvvmLight WP7 RTM

remember to paste the .zip on project templates folder.


C:\Users\Mariano\Documents\Visual Studio 2010\Templates\ProjectTemplates\Silverlight for Window Phone\Mvvm

I hope this could be Helpful.

May the code be with you.

Mariano Ravinale.

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License


Written by @mravinale

octubre 27, 2010 at 10:01 pm

Publicado en Windows Phone 7

Augmented Reality Accelerometer Demo for Windows Phone 7

leave a comment »

Today I would like to share a very good Augmented Reality application that would make to some of us the life a little more easier, and it is a good example where Augmented Reality can do and where can be used.

In this case AccelKit is a tool that simulates an accelerometer sensor for windows Phone 7, that may simplify our applications testing giving us a more real approach for our accelerometer measurements.

While I’ve been writing this article I thought that a emulator accelerometer it isn’t necesary if Windows Phone 7 has been realised, but in case that you are no lucky enough to have this awesome phone, it is a valid alternative.

So just for testing purposes today I just I’ve added some flavor to an existent project, nothing too difficult to do, but I did it because I really like the fly demo and is a very good application to learn xna.

First see this demo of the final result:

If you’re interested to do it and experiment with Windows Phone 7  Grab the files and tools

and follow this mini tutorial that I’ve prepared:

I would like to thanks to: Nikos Kastellanos for accelKit And Javier Ferrero for the fly demo .

May the code be with you!.

Mariano Ravinale

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License

Written by @mravinale

octubre 16, 2010 at 10:01 pm

Publicado en Windows Phone 7

Using Ria Services Soap and Windows Phone 7

with 4 comments

I remember last year or so at this time, I began to glimpse Ria Services, from that preview so far Ria Services grew strongly and became something more just than a framework for creating applications RAD (Rapid Application Development) for Silverlight.

Ria Services initially was conceived  to expose our business logic as a service, taking as a model our data access layer of EF, and get our domain in a client-side context to work with Silverlight in a dynamic manner, facilitating thus the development and access to data.

However for large scale applications we may have other requirements, such as: Exposing our services in a way that they can be consumed from other systems, or decouple the business logic from the services, to make it interchangeable or use other tools like workflow in the same, and/or perhaps also to decouple the data access layer to use other ORM than EF .

For both problems there are solutions that Ria Services team has implemented in order to continue using the facilities that it has given us working on Silverlight.
For now we will focus on the first problem, the interaction with other systems in the next article I`ll deal with the decoupling between layers.

With a friend we’ve share a vision of using RIA Services for an application that could access these services from external system in this case Windows 7 Phone!!!.

Make sure we have the latest version of Ria Services:

1. First of all we need to create a Web application in Asp.Net as Empty.

2. In this case, we can designate it as “SoapRiaService”.

3. Add a database where we will test our Employee table .

4. Then select Entity Framework 4 new item and write it the database conection name, you could use “SoapTestDbEntities”.

5. For this test and for now we will take the Employees table to create our mapping


6. Ok, we already have our entity Employee in our ORM. Now we need to do a solution build.

7. As a next step we need to create our domain service and get the interface for the basic CRUD operations in order to make it accessible to our client.
To achieve this we need to add a new component called Domain Service Class that is our Ria Service. In this case we may call it “EmployeeDomainService”.

8.  When we add a Domain Services class  using the wizard we can choose the entity that we need to apply the editing operations from the context of EF.
Choose properties enabling editing metadata generation, which will allow us to access the properties of validation of the entity, and also choose to expose an endpoint of Odate (REST)

9. For each method we add the decorator [invoke] in that way we generate the corresponding proxy methods in the client.

10) The Namespace and DomainServiceNameClass, give us a clue to find out the generated WCF service. The service address is:
1. http:// [host: port] / Services / [namespace] – [DomainServiceNameClass]. svc (the ‘.’ are replaced by ‘–’ )
2. Example: http://localhost:37390/Services/SoapRiaService-EmployeeDomainService.svc

11. Now we need to add the endpoint to access the SOAP services, if we do not want a REST enpoint , just remove the OData endpoint.

12. Having all the logic and configuration ready in our application we need to make sure to add the library Microsoft.ServiceModel.DomainServices.Hosting.dll address shown below.
But you have this path, be sure to install or reinstall WCF Silverlight RIA Services V1.0 for 4 and Visual Studio 2010

13. After adding the library and compiled the project, we just need to try it (F5) to be host in the IIS test server and then we can see our service at the following address:


14. If we want to see the WSDL Contract http://localhost:37390/Services/SoapRiaService-EmployeeDomainService.svc?wsdl

15. Now we’ve ready our service, to create our application in Windows Phone 7, first download the developer tools once installed create a new Windows project Panorama Phone Application (COOL!). use “WP7SoapRiaService” to name it, if you want.

16. Once created the application we’ll need to add a service reference as an address setting http://localhost:37390/Services/SoapRiaService-EmployeeDomainService.svc, then click on GO,at this time you should now see our service and operations exposed by Ria Services, rename the namespace to “EmployeeService” for example.

17. Let see the proxy classes that were created after giving Ok double clicking on the service reference.

18. Well now as a next step we could add the Reactive eXtensions(RX) reference ,
to control the asynchronous call to our Web Service, yap Reactive Extensions now comes within the Windows SDK Phone 7!!!.

19. Once you add the reference add the following code, on my last post I’ve explained RX, and I just added a spinner property to control the visibility:

20. Add a Spinner and bind it to the Visibility property, to control its visibility depending the data in our collection.

21. Run the application, and done you have the application ready!!

The first time when you execute this test you should be patience, because it could take a little longer time until you get the information from the server.

I Hope this post could be useful 😀

Project Download.

May the Code be with you!!!

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License

Written by @mravinale

septiembre 24, 2010 at 4:44 am

Reactive Extensions en Silverlight(RX)

leave a comment »

Si bien, la idea inicial era ir haciendo los post de forma incremental y que evolucione desde los patrones de diseño, hacia patrones mas avanzados como mvc, mvp hasta llegar a mvvm y empezar con Silverlight,  crei que es importante hablar de Rx ya que nos ayudara enormemente en Silverlight, y como estamos en el browser desde el lado cliente, seguramente habra muchas llamadas asyncronicas, es ahi donde Rx entra en juego.

podriamos definir a Rx(Reactive extensions) como una libreria para aplicaciones que necesiten hacer llamadas asincronicas y orientadas a eventos utilizando colecciones del tipo Observable.

En la pagina principal explica un poco el significado de esta nueva herramienta, que nos ayudará mucho a controlar y orquestar programaticamente estos eventos y llamadas.

Pagina principal, introduccion y Video Chanel 9.


Bien si se fijan en la pagina principal dice:

“Rx is a superset of the standard LINQ sequence operators that exposes asynchronous and event-based computations as push-based, observable collections via the new .NET 4.0 interfaces IObservable<T> and IObserver<T>.  These are the mathematical dual of the familiar IEnumerable<T> and IEnumerator<T> interfaces for pull-based, enumerable collections in the .NET Framework.”

Creo que este parrafo explica rapidamente de que se trata Rx. A mi entender lo que trata de expresar es que Rx es un conjunto de operaciones que utiliza los eventos a los que se suscribe como punto de entrada para llenar collecciones del tipo observable para que de esta manera nos avise cuando podemos empezar a consumir los datos como si estos estuvieran en una collecion o dispare el consumo de estos de forma automatica.

Pero volviendo a Silverlight podemos encontrarle gran utilidad si utilizamos el patron mvvm, ya que tenemos un binding entre la vista y el ViewModel por lo tanto nos ayudara a simplificar y automatizar el proceso de llamado al  servidor en busqueda de datos, por ejemplo, que es mas o menos lo que esta en el codigo de abajo.

En este caso lo que hice es crear una clase con patron Singleton como Clase y utilizarla como Modelo , para poderla reutilizar, y una llamada a un servicio para poder obtener datos,  en este caso,consumiremos los nombres de unas personas.

public class ServicePeopleModel{

        private static volatile ServicePeopleModel instance;
        private static object keyLock = new Object();

        public static ServicePeopleModel CurrentInstance {
            get {
                if (instance == null) {
                    lock (keyLock) {
                        instance = new ServicePeopleModel();
                return instance;

        /// <summary>
        /// Gets the remote people data.
        /// </summary>
        /// <returns></returns>
        public IObservable<Person> GetPeople() {

            SLPeopleServiceClient client = new SLPeopleServiceClient();

            var observable =
             //first we are going to listen the event, 
             //when is ready to fill our collection
             (from response in Observable.FromEvent
             <GetPeopleCompletedEventArgs>(client, "GetPeopleCompleted")
            //when the data arrives and the collection is ready,
            //I need to transform this data.
             from people in ConvertItems
            //and when it is ready return observable
            //collection, -and stay tuned
            //when all the operations
            //are done, because i'm gonna call you, 
            //says the observable collection.
            select people).ObserveOnDispatcher();
            //let's call the service

            return observable;


        /// <summary>
        /// Converts the items.
        /// </summary>
        public IEnumerable<Person> ConvertItems(List<String> response){
            var people = new List<Person>();
            response.ForEach(person => people.Add(
                new Person() {Name = person})
            return people;

public class Person {

    public string Name { get; set; }


Ok, ya hemos visto como hariamos nuestro modelo para pedir los datos a nuestro servicio, transformar los datosy devolver una coleccion con todos los datos, listos para utilizar.
Pero nos falta bindear estos datos contra la vista, para automatizar la tarea, de forma que cuando vengan los datos la vista lo muestre estos datos sin que tengamos que intervenir.

//On The PeopleViewModel

public class PeopleViewModel: ViewModelBase {

    /// <summary>
    /// Initializes a new instance of the PeopleViewModelclass.
    /// </summary>
    public PeopleViewModel() {
        var client = Observable.Empty<Person>();
        //we've suscribed to a changed event and we 
        //want to select the first person to show it on the view
        PeopleCollection.CollectionChanged += (s, e) => {
           SelectedPersonProperty = PeopleCollection[0].Name;

        //let's the magic starts
        client = ServicePeopleModel.CurrentInstance.GetPeople();

        //and suscribe us to the service result
        client.Subscribe((item) => {

     /// <summary>
     /// Gets or sets SelectedPersonProperty 
     /// </summary>
     public string SelectedPersonProperty {
         get {
             return _selectedPersonProperty ;
         set {
             if (_selectedPersonProperty == value) return;
                 _selectedPersonProperty = value;
             RaisePropertyChanged("SelectedPersonProperty ");
       /// <summary>
        /// Gets or sets the PeopleCollection.
        /// </summary>
        /// <value>PeopleCollection.</value>
        public ObservableCollection<Person> PeopleCollection{
            get {
                if(_popleCollection == null){
                    _peopleCollection = new ObservableCollection<Person>();
                return _peopleCollection;
            set {
                if (_peopleCollection == value) return;
                _peopleCollection= value;

Sin embargo si ven la pagina de ejemplos podran ver mushisimas mas aplicaciones de este framework, que a mi parecer es excelente tratando de unir el observer pattern y el Iterator, de forma sencilla y con altos beneficios en cantidad y calidad de codigo.

tengo otra aplicacion parecida hecha con Rx que posteare mas adelante, creo que vale la pena bajarselo y probarlo e irle toamndo la mano, creo que despues se va volviendo natural y uno le comienza a ver mas aplicaciones.

Dejo algunos links:

Para los amantes y expertos javascript (@cortezcristian) 😉

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.

Written by @mravinale

agosto 16, 2010 at 4:45 am