summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen/Native/TableView.cs
blob: 3cc1905e3d1ba6b5a6a0b56e826bdd87449df7bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using ElmSharp;

namespace Xamarin.Forms.Platform.Tizen.Native
{
	public class TableView : ListView
	{
		/// <summary>
		/// Initializes a new instance of the TableView class.
		/// </summary>
		public TableView(EvasObject parent)
			: base(parent) {
			_cellHandlers[typeof(SectionCell)] = new SectionCellHandler();
		}

		/// <summary>
		/// Sets the root of the table.
		/// </summary>
		/// <param name="root">TableRoot, which is parent to one or more TableSections.</param>
		public void ApplyTableRoot(TableRoot root)
		{
			Clear();
			foreach (TableSection ts in root)
			{
				AddSectionTitle(ts.Title);
				AddSource(ts);
			}
		}

		/// <summary>
		/// Sets the section title.
		/// </summary>
		void AddSectionTitle(string title)
		{
			Cell cell = new SectionCell()
			{
				Text = title
			};
			AddCell(cell);
		}

		/// <summary>
		/// Section cell handler. This is used for representing section cell.
		/// </summary>
		protected class SectionCellHandler : ListView.TextCellHandler
		{
			public SectionCellHandler() : base("group_index", detailPart: null)
			{
			}
		}

		class SectionCell : TextCell
		{
		}
	}
}