Saving user preferences in iOS using Xamarin

Introduction:
Xamarin provides a number of ways to save data in iOS using Local Storage. User preferences are generally stored in Library/Preferences/.
Xamarin iOs provides its built in mechanism i.e. instead of creating files directly in the directory it is suggested to use NSUserDefaults class to save data.

Description:
NSUserDefaults class provides its own built in mechanisms to save float, double, integers, Boolean and URL data. To save a custom object it should be converted to NSData object using NSUserDefaults.
Continue reading

Panorama control in Windows Phone

Introduction:
Windows Phone comes with a number of controls for display. Among them the Panorama Control is one the new controls for user interaction and display.

Description:
Panorama Control spans beyond the screen and helps user to chose from a number of panorama items. Each panorama item can consists of Grids, Stack Panels and other Phone controls. Image applied to Panorama as background spans across all the panorama items. Only one panorama item is visible at a time and user can make selection from it. A swipe gesture gives the next or previous Panorama item. Continue reading

Displaying alert dialog in Android using Xamarin

Introduction:
Alert dialog is a important part of any application. Conveying various information, error messages and even for taking confirmations from user can be done through alert dialog. Xamarin provides it’s own way of showing alert and conveying messages to the user.

Description:
Alerts in Xamarin are, an object of AlertDialog.Builder class, where AlertDialog is a subclass of Dialog class. Builder() is a method of AlertDialog class, which creates an alert dialog to display. We can add multiple buttons to this alert dialog. The builder takes the current context (Activity) and shows the Alert Box in the main thread(The UI thread). Continue reading

Relative layout design in Android using Xamarin

Introduction:
Xamarin provides different layout for designing the user interface in Android.
Some common ones being used are Relative Layout, Linear Layout, Grid Layout, Table Layout, Frame Layout etc. Most of them are understandable from their name itself. Here we will discuss about how to design using Relative Layout in Xamarin for Android.

Description:
As the name suggests, Relative Layout mainly makes use of the controls present in the Designer and places controls relatively to each other. The most important aspect of this design being the First element placed inside the tag. The places itself depending on the properties set for the children in the Relative Layout.
For example: Continue reading

MVVM Command Binding in Windows Phone using Custom Delegates

Introduction:
Binding commands in MVVM is a bit tricky, but if understood correctly then of a great use.
A simple command can be bound using a Delegate and the Icommand Interface to handle the function that is to be executed.

Description:
First of all we need to know what a Delegate is?
A Delegate is a reference to a function. A Delegate is much useful in an event execution. Although this example deals with a custom Delegate we can use a predefined delegates present in the System Namespace.

Secondly and most importantly, ICommand interface and its implementation. ICommand can be found in System.Windows.Input namespace. ICommand interface provides all the method signatures that are used to execute a command in MVVM. Continue reading

Custom commands in Windows store Message Dialogs

Introduction:
Message Dialogs are important part of windows store app and they help us providing popup messages and quick information in required places. Typically a message dialog covers the entire screen and by default has a close button. Windows store apps allow us to change these default characteristics of a message dialog.

Description:
The default close button in message dialog for windows store app can be removed and new buttons with custom click event handlers can be added to it. These events can be then later used to catch user interactions with the information. Continue reading

Canvas animation in windows store apps

Introduction:
Animations are key features to make an app interactive and lively. It can occur between Opacity, change in X & Y coordinates, Bounce effect, Size changes etc. Storyboards are the most effective way to implement an animation.

Description:
In this example we will go through an animation, which would make a rectangular box move from left to right with position and time span being specified.
To make such kind of animation first of all it is required to animate the Canvas.Left property of an element using the DoubleAnimation class. This class makes use of the Duration specified in the format “hour:minute:second” and animates the Canvas.Left property of the element according to the time period specified. Other property includes AutoReverse, which reverses the animation (the same animation in opposite manner)and RepeatBehavior, which specifies how many times the animation can be repeated. Continue reading

Selecting phone book contacts in Windows Phone using MVVM

Introduction:
Windows phone API allows us to access the phone book contact list using the code. Contacts are fetched in an observable list with details like Display Name, Company, Phone Number etc bundled in the Contacts object. These contacts can then be displayed in a list box with required details.
Following examples demonstrates the same.

Description:
We will use the Contacts class to fetch the details of phone book contacts.
To start with windows phone Contacts class first and foremost requirement is that of adding a capability of ID_CAP_CONTACTS in the WMAppManifest.xml file.
To add a capability either edit the XML or select the Capabilities tab from WMAppManifest.xml file and select the ID_CAP_CONTACTS check box located in the left part of the screen. Continue reading

Page navigation in windows store app

Introduction:
Navigation to different pages is an important part of any application. In Windows Store App it is handled by the Frame class.

Description:
A Windows Store app consist of a Parent frame and pages inside it. This frame provides a method named Navigate() that handles all the navigation between the pages. Navigate method takes the type of Page to navigate as parameters, additionally we can also specify the data to pass to the next page. The Navigate method triggers an event named OnNavigatedFrom inside the page when navigating away from the page and OnNavigatedTo in the page to which we are navigating. The data passed during navigation is caught in the NavigationEventArgs object of the Events above.
The parameter passed from the Previous page is stored in the Parameter property of the NavigationEventArgs that is received while navigating. Continue reading

Displaying message dialog in Metro apps

Introduction:
Popup messages play a vital role for an application. Confirmation boxes, Alert messages and displaying specific sets information are done in Windows store app through a message dialog that pops up on the screen covering the entire width of the screen. These message box design are by default provided by Microsoft.

Description:
Message Dialog blocks the user interaction with other objects on the screen and dims the Screen background. So it should be used accordingly. Continue reading