A Look at MonoTouch.Dialog

| by Jonathan Allen Follow 462 Followers on Feb 15, 2012. Estimated reading time: 1 minute |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

MonoTouch.Dialog is a UI development toolkit designed to dramatically reduce the amount of boilerplate code needed to create application screens. Through the creative use of attributes, screens are dynamically built from class definitions. Alternately they can be programmatically created or loaded from a JSON document.

MonoTouch.Dialog or MT.D consists of two libraries. A low-level Elements API allows developers to define a hierarchal tree of elements that represent screens and their components. This allows for dynamic UI construction (think server-generated forms). This is also the layer that supports loading JSON-based screen definitions.

The high-level Reflection API, also known as the Binding API, uses annotated classes to declaratively construct user interfaces. These classes can represent the model objects themselves or be coded as wrappers around them.

A MT.D screen is composed of four basic parts. The DialogViewController replaces iOS’s normal TableViewController and can be used the same way. The next piece is the RootElement, a renderless container that holds Sections and Elements. A section is a logical grouping of controls while an element represents a single data-bound control.

When using the Reflection API, sections and elements are laid out in the same order as they are declared in the source code. This means it is essential that you disable any code cleanup tools that can reorder the properties and methods in a source file.

In order to go beyond the basic controls, advanced developers will want to learn how to work with the OwnerDrawnElement and Element base classed. OwnerDrawnElement allows developers to define their own look and feel by directly manipulating a CGContext while Element gives them full control.

MonoTouch.Dialog specifically avoids the topic of data validation. They recommend that validation be manually implemented and triggered when the user presses a “next” or “done” button.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread


Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you