summaryrefslogtreecommitdiff
path: root/Juick/Classes/DeferredLoadListBoxItem.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/Classes/DeferredLoadListBoxItem.cs')
-rw-r--r--Juick/Classes/DeferredLoadListBoxItem.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/Juick/Classes/DeferredLoadListBoxItem.cs b/Juick/Classes/DeferredLoadListBoxItem.cs
new file mode 100644
index 0000000..97bfc18
--- /dev/null
+++ b/Juick/Classes/DeferredLoadListBoxItem.cs
@@ -0,0 +1,45 @@
+// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// This code released under the terms of the Microsoft Public License
+// (Ms-PL, http://opensource.org/licenses/ms-pl.html).
+
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Juick.Classes
+{
+ /// <summary>
+ /// Implements a subclass of ListBoxItem that is used in conjunction with
+ /// the DeferredLoadListBox to defer the loading of off-screen items.
+ /// </summary>
+ public class DeferredLoadListBoxItem : ListBoxItem
+ {
+ private object _maskedContent;
+ private DataTemplate _maskedContentTemplate;
+
+ internal bool Masked { get; set; }
+
+ internal void MaskContent()
+ {
+ if (!Masked)
+ {
+ _maskedContent = Content;
+ _maskedContentTemplate = ContentTemplate;
+ Content = null;
+ ContentTemplate = null;
+ Masked = true;
+ }
+ }
+
+ internal void UnmaskContent()
+ {
+ if (Masked)
+ {
+ ContentTemplate = _maskedContentTemplate;
+ Content = _maskedContent;
+ _maskedContentTemplate = null;
+ _maskedContent = null;
+ Masked = false;
+ }
+ }
+ }
+}