Alternative Footer property for a Monotouch Dialog Section that supports updating after the Initial Load. See this blog post http://munkiisoft.com/blog/archive/2015/06/10/updating-the-footer-on-a-monotouch-dialog-section.aspx
/// <summary> | |
/// MonoTouch Dialog Section super class | |
/// </summary> | |
public class Section : CrossUI.Touch.Dialog.Elements.Section | |
{ | |
/// <summary> | |
/// Initializes a new instance of the <see cref="Section"/> class. | |
/// </summary> | |
public Section() : base() | |
{ | |
} | |
/// <summary> | |
/// Initializes a new instance of the <see cref="Section"/> class. | |
/// </summary> | |
/// <param name="caption">The header to display</param> | |
public Section(string caption) : base(caption) | |
{ | |
} | |
/// <summary> | |
/// Gets or sets the bindable footer. | |
/// </summary> | |
/// <value> | |
/// The bindable footer. | |
/// </value> | |
public string BindableFooter | |
{ | |
get | |
{ | |
return this.Footer; | |
} | |
set | |
{ | |
if (this.Footer == value) | |
{ | |
return; | |
} | |
this.Footer = value; | |
this.UpdateSection(); | |
} | |
} | |
/// <summary> | |
/// Updates the section. | |
/// </summary> | |
private void UpdateSection() | |
{ | |
RootElement rootElement = this.Parent as RootElement; | |
if (rootElement != null) | |
{ | |
// Need to get a Index\IndexPath to this Section. I have been unable to find anyway to do this other than | |
// looping through the Parent's Sections looking for the Section and then taking a note of the numeric index | |
int index = -1; | |
foreach (CrossUI.Touch.Dialog.Elements.Section section in rootElement.Sections) | |
{ | |
index++; | |
if (section == this) | |
{ | |
break; | |
} | |
} | |
if (index >= 0) | |
{ | |
rootElement.TableView.BeginUpdates(); | |
rootElement.TableView.ReloadSections(NSIndexSet.FromIndex(index), UITableViewRowAnimation.None); | |
rootElement.TableView.EndUpdates(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment