Xamarin Forms and WindnTrees View Model

Abstract

In this tutorial we'll learn about WindnTrees ObserverObject view model data structure and its importance while working with Xamarin Forms.

Keywords: WindnTrees View Model, CRUDView, Xamarin Forms, CRUD2CRUD, CRUDS
  • Introduction

    WindnTrees view model (VM) consists of following major attribute categories and properties:

    1. Data Content
    2. Selection Content
    3. Status Fields and Properties

    Data content categories include object and listing content and is defined by following property names:

    1. ObjectModel
    2. ContentModel
    3. ContentsListModel

    "ObjectModel" and "ContentModel" deals in object data presentation and communication where as "ContentsListModel" deals in listing data.

    "Selection Content" is a "ViewInput (WebInput, SearchInput)" reference class object that includes following fields and properties for retrieving appropriate records, a few are mentioned here as an example:

    1. key
    2. keys
    3. keyword
    4. keywords
    5. options

    Server side controller de-serializes selection input using "WebInput" with enough class definition. Please read through WindnTrees.ICRUDS.Standard API library from invincibletec.com.

    "Status Fields and Properties" are used by Xamarin Form's view for displaying processing status with related messages.

    WindnTrees View Model and Data Input

    Controllers provide generalized data communication either of an entity type or a conceptual data class, in either way, we need to program view for data input. Xamarin Form's view uses BindingContext with different GUI controls for taking input and saves in WindnTrees "ContentModel" or "SearchInput" bound through generalized type properties. Input stored is then communicated between CRUDView(s) and CRUDController(s).

    Data input models include:

    1. ContentModel
    2. SearchInput

    WindnTrees View Model Commands

    By default ObserverObject based ViewModel include following commands with pre-defined implementations:

    1. CreateCommand
    2. ReadCommand
    3. UpdateCommand
    4. DeleteCommand
    5. ListCommand

    However, WindnTrees view model must be initialized with already defined commands for using with Xamarin Forms view.

    1. CreateCommand = new Command(CreateCommandAction);
    2. ReadCommand = new Command(ReadCommandAction);
    3. UpdateCommand = new Command(UpdateCommandAction);
    4. DeleteCommand = new Command(DeleteCommandAction);
    5. ListCommand = new Command(ListCommandAction);

    CreateCommand invokes "create", ReadCommand invokes "read", UpdateCommand invokes "update", DeleteCommand invokes "delete" and ListCommand invokes "list" on server side CRUDController.

  • WindnTrees View Model and WindnTrees.Abstraction

    WindnTrees view model is WindnTrees.Abstraction controller actions response ready class component.

    WindnTrees.Abstraction response CRUDL actions with following object response data set:

    {
    	content: { }
    	errors: {}
    }
    

    Where content data object is reported in CRUDView.OnViewModel, CRUDView.OnContentObject and CRUDView.OnObjectViewModel events. WindnTrees.Abstraction response with following listing data set:

    {
    	contents: [{},....,{}]
    	errors: {}
    }
    

    Where contents listing data is reported in CRUDView.OnViewModel, CRUDView.OnContentObjectList and CRUDView.OnListViewModel. CRUDMethod invocations are reported in CRUDView.OnViewModel and CRUDView.OnListViewModel where as all other CRUDView default CRUDL actions are reported in CRUDView.OnViewModel and CRUDView.OnContentObjectList.

    WindnTrees View Model and WindnTrees.Core

    WindnTrees view model is WindnTrees.Core controller actions response ready class component. WindnTrees.Core response CRUDL actions with following object response data set:

    {
    	content: { }
    	errors: {}
    }
    

    Where content data object is reported in CRUDView.OnViewModel, CRUDView.OnContentObject and CRUDView.OnObjectViewModel events. WindnTrees.Core response with following listing data set:

    {
    	contents: [{},....,{}]
    	errors: {}
    }
    

    Where contents listing data is reported in CRUDView.OnViewModel, CRUDView.OnContentObjectList and CRUDView.OnListViewModel. CRUDMethod invocations are reported in CRUDView.OnViewModel and CRUDView.OnListViewModel where as all other CRUDView default CRUDL actions are reported in CRUDView.OnViewModel and CRUDView.OnContentObjectList.

    Summary

    WindnTrees view model combines both object and listing data that fulfills the purpose of CRUDL communication. One view model fits both object and listing data management.