Introduction

The points I?ll mention in this post to help quickly start developing your first Win Store App

  1. MVVM and MVC.
  2. Serialization and Deserialization.
  3. Dynamic objects.
  4. Storage, files , settings and DB.
  5. UI and Animation.

  


MVVM (Model-View-ViewModel) and MVC (Model-View-Controller).

We will not go throw both models because there are a lot of good articles on the internet describing the differences between them but here is a quick illustration based on my own point of view:

In MVC your controllers (Front Controller) are responsible for getting the data from the view and pass it to your application business logic layer and vice versa.

In MVVM your ViewModel automatically change the view and vice versa so you?re just responsible for ViewModel ? Business Logic integration.

 


Serialization and Deserialization.

In asp.net if you want to serialize an object you need to add the Serializable attribute to your class.

[Serializable()]
public class MyData
{
    public string Name;
 
    [NonSerialized()]
    public string Email;
}

In Windows Store Apps you add a DataContract and DataMember attribute like in WCF

[DataContract]
public class MyData
{
    [DataMember]
    public string Name { get; set; }
 
    public string Email { get; set; }
}

And here 2 methods will help you in your store app

public static T Deserialize<T>(string json)
{
    var _Bytes = Encoding.Unicode.GetBytes(json);
 
    using (MemoryStream _Stream = new MemoryStream(_Bytes))
    {
        var _Serializer = new DataContractJsonSerializer(typeof(T));
        return (T)_Serializer.ReadObject(_Stream);
    }
}
  
public static string Serialize(object instance)
{
    using (MemoryStream _Stream = new MemoryStream())
    {
        var _Serializer = new DataContractJsonSerializer(instance.GetType());
  
        _Serializer.WriteObject(_Stream, instance);
        _Stream.Position = 0;
  
        using (StreamReader _Reader = new StreamReader(_Stream))
        {
            return _Reader.ReadToEnd();
        }
    }
}

 


Dynamic Objects.

Dynamic type in Store Apps will help much in many ways one of the is getting data from web services

//JObject in Newtonsoft library
dynamic resultObj = JObject.Parse(response);
 
string obj1 = resultObj.Name;
string obj2 = resultObj.Address;
  
List<string> obj3=resultObj.Data;

I know you?ll tell me that dynamic type is now in asp.net but there are a lot of people still using old .net framework

 


Storage, files, settings and DB.

In asp.net you can connect directly to SQL server but in windows store apps you can?t (You may a public web service as broker because in Store Apps if your app is connecting to a local service it won?t be pass in the store validation) but you can use SQLite in your Store App which provides you a basic DB functionality.

In store app you don?t have the full access throw the file system of the machine like asp.net (Of course if you are an admin in asp.net) there is a restriction in file access as an example you can?t read a file by giving it the absolute location like ?D:\myfile.txt?, you can access the documents library (My documents) and you need a permission for that or you can access files inside application storage or by file picker

Here is a code sample for file access

Something to mention is the application settings, app settings is a permanent dictionary for your application  Each setting can be up to 8K bytes in size and each composite setting can be up to 64K bytes in size.

var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
   
// Create a simple setting
localSettings.Values["exampleSetting"] = "Hello Windows";
   
// Read data from a simple setting
Object value = localSettings.Values["exampleSetting"];

Maybe you can use the app settings instead of DB session.

  


UI and Animation.

Windows Store Apps has its own design guide lines which will help you to get start with the perfect controls and application scenario for you. One thing I always say in my Design Guidelines sessions is that I want the consumer to feel like he took a deep breath once he saw your application.

Those links will help you to get started with Windows Store Apps design Guide lines 

And about the animation there is a build in animations in some controls like GridView drag and Drop , Delete and Add , etc?

But What I?m talking about is to make a good use of the animation library in Windows Store App.

There are four type of animation :-

  1. Theme animations.
  2. T heme transitions.
  3. Visual transitions.
  4. Storyboarded animations.

And here are three types of Content transition and entrance transition I usually use

  1. Swipe gestures
  2. Drag/drop
  3. Fade in/out, and crossfade

And for more about animation check this link.