diff options
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen/Native/TableView.cs')
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Native/TableView.cs | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Native/TableView.cs b/Xamarin.Forms.Platform.Tizen/Native/TableView.cs new file mode 100644 index 00000000..73388a84 --- /dev/null +++ b/Xamarin.Forms.Platform.Tizen/Native/TableView.cs @@ -0,0 +1,67 @@ +using ElmSharp; + +namespace Xamarin.Forms.Platform.Tizen.Native +{ + /// <summary> + /// Extends the ListView class to provide TableView class implementation. + /// </summary> + public class TableView : ListView + { + + static readonly SectionCellRenderer _sectionCellRenderer = new SectionCellRenderer(); + /// <summary> + /// Initializes a new instance of the TableView class. + /// </summary> + public TableView(EvasObject parent) + : base(parent) { + } + + /// <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); + } + } + + protected override CellRenderer GetCellRenderer(Cell cell, bool isGroup = false) + { + if (cell.GetType() == typeof(SectionCell)) + { + return _sectionCellRenderer; + } + return base.GetCellRenderer(cell, isGroup); + } + + /// <summary> + /// Sets the section title. + /// </summary> + void AddSectionTitle(string title) + { + Cell cell = new SectionCell() + { + Text = title + }; + AddCell(cell); + } + + internal class SectionCellRenderer : GroupCellTextRenderer + { + public SectionCellRenderer() + { + DetailPart = "null"; + } + protected SectionCellRenderer(string style) : base(style) { } + } + class SectionCell : TextCell + { + } + } +} + |