MonoTouch.Dialog.DialogViewController Class
The DialogViewController is the main entry point to use MonoTouch.Dialog, it provides a simplified API to the UITableViewController.

See Also: DialogViewController Members

Syntax

public class DialogViewController : UIKit.UITableViewController

Remarks

The DialogViewController renders the contents assigned to the Root property of type RootElement. This can be either passed at construction time or assigned after the DialogViewController has been created.

RootElements can be created either manually with the "Elements" API by creating the various nodes necessary to render the information. You would use this if you need control, if you want to extend the features supported by MonoTouch.Dialogs or if you want to dynamically generate the content for your dialog. This is what is used for example in TweetStation for the main timeline views.

The Element API is the most complete API and the most customizable one. This is how you would create a user interface definition:

c# Example

        var root = new RootElement ("Settings") {
          new Section (){
            new BooleanElement ("Airplane Mode", false),
            new RootElement ("Notifications", 0, 0) {
              new Section (null, 
                  "Turn off Notifications to disable Sounds\n" +
                  "Alerts and Home Screen Badges for the."){
                new BooleanElement ("Notifications", false)
              }
            }},
          new Section (){
            new RootElement ("Brightness"){
              new Section (){
                new FloatElement (null, null, 0.5f),
                new BooleanElement ("Auto-brightness", false),
				new UILabel ("I am a simple UILabel!"),
              }
            },
          },
          new Section () {
            new EntryElement ("Login", "enter", "miguel"),
            new EntryElement ("Password", "enter", "password", true),
            new DateElement ("Select Date", DateTime.Now),
            new TimeElement ("Select Time", DateTime.Now),
          },
	};
	

This creates a toplevel RootElement that will label the view as "Settings", and then will show three sectionts. The first section contains a boolean value (implemented with a UISwitch) followed by a nested table labeled "Notifications". If the user taps on that notifications cell, a new table will be shown with the new Boolean Element. The second and third section show some common elements that can be used.

Additionally, there is a trivial Reflection-based constructor that can be used for quickly putting together dialogs, for example, creating an account page is as trivial as:

c# Example

    class AccountInfo {
        [Section]
        public bool AirplaneMode;
    
        [Section ("Data Entry", "Your credentials")]
    
        [Entry ("Enter your login name")]
        public string Login;
    
        [Caption ("Password"), Password ("Enter your password")]
        public string passwd;

        [Section ("Travel options")]
        public SeatPreference preference;
  }

    void Setup ()
    {
        account = new AccountInfo ();
    
        var bc = new BindingContext (this, account, "Seat Selection");
    }
	

Autorotation is supported by default by setting the Autorotate property in the DialogViewController. Setting this value will propagate to the various components that are shiped with MonoTouch.Dialog like the WebView and the date and time pickers

Pull to Refresh is a visual effect originally found in Tweetie2 which became a popular effect among many applications.

To add automatic pull-to-refersh support to your dialogs, you only need to do two things: hook up an event handler to be notified when the user pulls the data and notify the DialogViewController when the data has been loaded to go back to its default state.

Hooking up a notification is simple, just connect to the RefreshRequested event on the DialogViewController, like this:

c# Example

        dvc.RefreshRequested += OnUserRequestedRefresh;
	

Then on your method OnUserRequestedRefresh, you would queue some data loading, request some data from the net, or spin a thread to compute the data. Once the data has been loaded, you must notify the DialogViewController that the new data is in, and to restore the view to its default state, you do this by calling ReloadComplete:

c# Example

	  dvc.ReloadComplete ();
	

To support searching, set the EnableSearch property on your DialogViewController. You can also set the SearchPlaceholder property to use as the watermark text in the search bar.

Searching will change the contents of the view as the user types, it searches the visible fields and shows those to the user. The DialogViewController exposes three methods to programatically initiate, terminate or trigger a new filter operation on the results: StartSearch, FinishSearch, PerformFilter.

The system is extensible, so you can alter this behavior if you want, details are below.

There is a high-level reflection API that can be used for quickly creating user interfaces. For more information on this, see the MonoTouch.Dialog.BindingContext documentation.

Requirements

Namespace: MonoTouch.Dialog
Assembly: MonoTouch.Dialog-1 (in MonoTouch.Dialog-1.dll)
Assembly Versions: 0.0.0.0