Created
June 10, 2015 08:24
-
-
Save munkii/9709dad0bfef4bb43a34 to your computer and use it in GitHub Desktop.
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <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