MonoTouch.Dialog.Element.GetIndexPath C# (CSharp) Method

GetIndexPath() public method

public GetIndexPath ( ) : NSIndexPath
return NSIndexPath
		public NSIndexPath GetIndexPath() { 
			var section = Parent as Section;
			if (section == null)
				return null;
			var root = section.Parent as RootElement;
			if (root == null)
				return null;
			
			int row = 0;
			foreach (var element in section.Elements){
				if (element == this){
					int nsect = 0;
					foreach (var sect in root.Sections){
						if (section == sect){
							return NSIndexPath.FromRowSection (row, nsect);
						}
						nsect++;
					}
				}
				row++;
			}
			return null;
		}

Usage Example

示例#1
0
        public void Reload(Element element, UITableViewRowAnimation animation)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            var section = element.Parent as Section;

            if (section == null)
            {
                throw new ArgumentException("Element is not attached to this root");
            }
            var root = section.Parent as RootElement;

            if (root == null)
            {
                throw new ArgumentException("Element is not attached to this root");
            }
            var path = element.GetIndexPath();

            if (path == null)
            {
                return;
            }
            if (TableView != null)
            {
                TableView.ReloadRows(new NSIndexPath [] { path }, animation);
            }
        }
All Usage Examples Of MonoTouch.Dialog.Element::GetIndexPath