﻿<?xml version="1.0" encoding="utf-8"?>
<CodeTemplates version="3.0">
  <CodeTemplate version="2.0">
    <Header>
      <_Group>C#</_Group>
      <Version>1.0</Version>
      <MimeType>text/x-csharp</MimeType>
      <Shortcut>uitvc</Shortcut>
      <_Description>Template for UITableViewController</_Description>
      <TemplateType>Expansion</TemplateType>
    </Header>
    <Variables>
      <Variable name="name" isIdentifier="true">
        <Default>name</Default>
        <_ToolTip>Controller name</_ToolTip>
      </Variable>
      <Variable name="namespace">
        <Default>namespace</Default>
        <_ToolTip>ProjectNameGoesHere</_ToolTip>
      </Variable>
      <Variable name="instancename" isIdentifier="true">
        <Default>tvc</Default>
        <_ToolTip>UITableViewController instance name</_ToolTip>
      </Variable>
      <Variable name="title">
        <Default>Title</Default>
        <_ToolTip>Title for UITableViewController</_ToolTip>
      </Variable>
    </Variables>
    <Code><![CDATA[using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;

namespace $namespace$
{
		[MonoTouch.Foundation.Register("$name$")]
		public partial class $name$ : UITableViewController {
			static NSString kCellIdentifier = new NSString ("MyIdentifier");
		
			//
			// Constructor invoked from the NIB loader
			//
			public $name$ (IntPtr p) : base (p) {}
		
			
			//
			// The data source for our TableView
			//
			class DataSource : UITableViewDataSource {
				$name$ $instancename$;
				
				public DataSource ($name$ $instancename$)
				{
					this.$instancename$ = $instancename$;
				}
				
				public override int RowsInSection (UITableView tableView, int section)
				{
					return 1;
				}
		
				public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
				{
					var cell = tableView.DequeueReusableCell (kCellIdentifier);
					if (cell == null){
						cell = new UITableViewCell (UITableViewCellStyle.Default, kCellIdentifier);
					}
				
					// Customize the cell here...
				
					return cell;
				}
			}
		
			//
			// This class receives notifications that happen on the UITableView
			//
			class TableDelegate : UITableViewDelegate {
				$name$ $instancename$;
	
				public TableDelegate ($name$ $instancename$)
				{
					this.$instancename$ = $instancename$;
				}
				
				public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
				{
					Console.WriteLine ("$namespace$: Row selected {0}", indexPath.Row);
					
				}
			}
			
			public override void ViewDidLoad ()
			{
				base.ViewDidLoad ();
				Title = "$title$";
				
				TableView.Delegate = new TableDelegate (this);
				TableView.DataSource = new DataSource (this);
			}
			
	}
}
]]></Code>
  </CodeTemplate>
</CodeTemplates>
