diff options
Diffstat (limited to 'Xamarin.Forms.Platform.iOS/Extensions/CellExtensions.cs')
-rw-r--r-- | Xamarin.Forms.Platform.iOS/Extensions/CellExtensions.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Extensions/CellExtensions.cs b/Xamarin.Forms.Platform.iOS/Extensions/CellExtensions.cs new file mode 100644 index 00000000..ca05bc54 --- /dev/null +++ b/Xamarin.Forms.Platform.iOS/Extensions/CellExtensions.cs @@ -0,0 +1,41 @@ +using System; +#if __UNIFIED__ +using Foundation; + +#else +using MonoTouch.Foundation; +#endif + +namespace Xamarin.Forms.Platform.iOS +{ + internal static class CellExtensions + { + internal static NSIndexPath GetIndexPath(this Cell self) + { + if (self == null) + throw new ArgumentNullException("self"); + + NSIndexPath path; + + if (self.RealParent is ListView) + { + var section = 0; + var til = TemplatedItemsList<ItemsView<Cell>, Cell>.GetGroup(self); + if (til != null) + section = TemplatedItemsList<ItemsView<Cell>, Cell>.GetIndex(til.HeaderContent); + + var row = TemplatedItemsList<ItemsView<Cell>, Cell>.GetIndex(self); + path = NSIndexPath.FromRowSection(row, section); + } + else if (self.RealParent is TableView) + { + var tmPath = TableView.TableSectionModel.GetPath(self); + path = NSIndexPath.FromRowSection(tmPath.Item2, tmPath.Item1); + } + else + throw new NotSupportedException("Unknown cell parent type"); + + return path; + } + } +}
\ No newline at end of file |