summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/TableModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Core/TableModel.cs')
-rw-r--r--Xamarin.Forms.Core/TableModel.cs76
1 files changed, 76 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core/TableModel.cs b/Xamarin.Forms.Core/TableModel.cs
new file mode 100644
index 00000000..866b7a69
--- /dev/null
+++ b/Xamarin.Forms.Core/TableModel.cs
@@ -0,0 +1,76 @@
+using System;
+
+namespace Xamarin.Forms
+{
+ internal abstract class TableModel
+ {
+ public virtual Cell GetCell(int section, int row)
+ {
+ object item = GetItem(section, row);
+ var cell = item as Cell;
+ if (cell != null)
+ return cell;
+
+ return new TextCell { Text = item.ToString() };
+ }
+
+ public virtual Cell GetHeaderCell(int section)
+ {
+ return null;
+ }
+
+ public abstract object GetItem(int section, int row);
+
+ public abstract int GetRowCount(int section);
+
+ public abstract int GetSectionCount();
+
+ public virtual string[] GetSectionIndexTitles()
+ {
+ return null;
+ }
+
+ public virtual string GetSectionTitle(int section)
+ {
+ return null;
+ }
+
+ public event EventHandler<EventArg<object>> ItemLongPressed;
+
+ public event EventHandler<EventArg<object>> ItemSelected;
+
+ public void RowLongPressed(int section, int row)
+ {
+ RowLongPressed(GetItem(section, row));
+ }
+
+ public void RowLongPressed(object item)
+ {
+ if (ItemLongPressed != null)
+ ItemLongPressed(this, new EventArg<object>(item));
+
+ OnRowLongPressed(item);
+ }
+
+ public void RowSelected(int section, int row)
+ {
+ RowSelected(GetItem(section, row));
+ }
+
+ public void RowSelected(object item)
+ {
+ if (ItemSelected != null)
+ ItemSelected(this, new EventArg<object>(item));
+
+ OnRowSelected(item);
+ }
+
+ protected virtual void OnRowLongPressed(object item)
+ {
+ }
+
+ protected virtual void OnRowSelected(object item)
+ {
+ }
+ }
+} \ No newline at end of file