MonoMobile.Views.ListSource.WillDisplay C# (CSharp) Method

WillDisplay() public method

public WillDisplay ( UITableView tableView, UITableViewCell cell, NSIndexPath indexPath ) : void
tableView UITableView
cell UITableViewCell
indexPath NSIndexPath
return void
		public override void WillDisplay(UITableView tableView, UITableViewCell cell, NSIndexPath indexPath)
		{
			var updated = false;

			var sectionData = GetSectionData(0);
			var section = Sections[0];
			if (section.Views.ContainsKey(cell))
			{
				var views = section.Views[cell];
	
				if (views.Count > 0)
				{
					foreach (var view in views)
					{
						var dc = view as IDataContext<object>;
						if (dc != null)
						{
							dc.DataContext = GetSectionData(0)[indexPath.Row];
						}

						var updateable = view as IUpdateable;
						if (updateable != null)
						{
							updateable.UpdateCell(cell, indexPath);
							cell.SetNeedsDisplay();
							updated = true;
						}
					}
				}
			}
		
			// Do default since no views have done an update
			if (!updated)
			{
				if (IsRootCell)
				{
					cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
					cell.TextLabel.Text = Caption;
					if (IsMultiselect && cell.DetailTextLabel != null)
					{
						cell.DetailTextLabel.Text = SelectedItems.Count.ToString();
					}
					else
					{
						if (SelectedItem != null)
						{
							if (ReplaceCaptionWithSelection)
								cell.TextLabel.Text = SelectedItem.ToString();
							else
								if (cell.DetailTextLabel != null)
									cell.DetailTextLabel.Text = SelectedItem.ToString();
						}
					}
				}
				else
				{
					if (sectionData.Count > 0 && sectionData[indexPath.Row] != null)
					{
						cell.TextLabel.AdjustsFontSizeToFitWidth = true;
						cell.TextLabel.Text = sectionData[indexPath.Row].ToString();
					}
					else
						Console.WriteLine("No Data: for row {0}, section {1}", indexPath.Row, indexPath.Section);
				}
			}
		}