summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/GalleryPages/DisposeGallery.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Controls/GalleryPages/DisposeGallery.cs')
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/DisposeGallery.cs58
1 files changed, 58 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls/GalleryPages/DisposeGallery.cs b/Xamarin.Forms.Controls/GalleryPages/DisposeGallery.cs
new file mode 100644
index 00000000..910c1af7
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/DisposeGallery.cs
@@ -0,0 +1,58 @@
+´╗┐using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class DisposeGallery : ContentPage
+ {
+ public DisposeGallery ()
+ {
+ var disposePage = new DisposePage ();
+
+ var pushButton = new Button {Text = "Push disposable page"};
+ var pushModalButton = new Button {Text = "PushModal disposable page"};
+
+ pushButton.Clicked += (sender, args) => {
+ disposePage.PopAction = () => Navigation.PopAsync ();
+ Navigation.PushAsync (disposePage);
+ };
+ pushModalButton.Clicked += (sender, args) => {
+ disposePage.PopAction = () => Navigation.PopModalAsync ();
+ Navigation.PushModalAsync (disposePage);
+ };
+
+ var appearingLabel = new Label {Text = "Appearing not sent"};
+ var disappearingLabel = new Label {Text = "Disappearing not sent"};
+
+ var disposedPageLabel = new Label {Text = "Page renderer not yet disposed"};
+ var disposedLabelsLabel = new Label {Text = "Number of disposed labels: 0"};
+
+ disposePage.Appearing += (sender, args) => appearingLabel.Text = "Appearing sent";
+ disposePage.Disappearing += (sender, args) => disappearingLabel.Text = "Disappearing sent";
+ disposePage.RendererDisposed += (sender, args) => {
+ disposedPageLabel.Text = "Page renderer disposed";
+ // give some time for this to propogate
+ Device.StartTimer (TimeSpan.FromSeconds (1), () => {
+ disposedLabelsLabel.Text = "Number of disposed labels: " + disposePage.DisposedLabelCount;
+ return false;
+ });
+
+ };
+
+ Content = new StackLayout {
+ Padding = new Thickness (20),
+ Children = {
+ pushButton,
+ pushModalButton,
+ appearingLabel,
+ disappearingLabel,
+ disposedLabelsLabel,
+ disposedPageLabel
+ }
+ };
+ }
+ }
+}