Merge pull request #81 from ericsink/master

attempt to properly unsubscribe the click handler for List cells.
This commit is contained in:
Frank A. Krueger 2018-02-21 15:21:20 -08:00 committed by GitHub
commit 4ef14afc7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -48,6 +48,8 @@ namespace Ooui.Forms.Renderers
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
UnsubscribeCellClicks();
base.Dispose(disposing); base.Dispose(disposing);
if (disposing && !_disposed) if (disposing && !_disposed)
@ -56,8 +58,17 @@ namespace Ooui.Forms.Renderers
} }
} }
private void UnsubscribeCellClicks()
{
foreach (var c in _cells)
{
c.Click -= ListItem_Click;
}
}
private void UpdateItems() private void UpdateItems()
{ {
UnsubscribeCellClicks();
_cells.Clear(); _cells.Clear();
var items = TemplatedItemsView.TemplatedItems; var items = TemplatedItemsView.TemplatedItems;