From 0ea1b7a7d20a5820ed3b7847f1e9a296cf483005 Mon Sep 17 00:00:00 2001 From: ProJend Date: Sat, 7 Oct 2023 20:21:34 +0800 Subject: [PATCH] Fix memory leaks --- TrueLove.UWP/Views/CommentsPage.xaml.cs | 6 ++++++ TrueLove.UWP/Views/ImagesPage.xaml.cs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/TrueLove.UWP/Views/CommentsPage.xaml.cs b/TrueLove.UWP/Views/CommentsPage.xaml.cs index e181559..5514eb9 100644 --- a/TrueLove.UWP/Views/CommentsPage.xaml.cs +++ b/TrueLove.UWP/Views/CommentsPage.xaml.cs @@ -5,6 +5,7 @@ using Windows.UI.Core; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Navigation; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -23,6 +24,11 @@ public CommentsPage() } + protected override void OnNavigatedFrom(NavigationEventArgs e) + { + Window.Current.Activated -= OnWindowActivated; + } + async void GetSourceCode() { RefreshButton.IsEnabled = false; diff --git a/TrueLove.UWP/Views/ImagesPage.xaml.cs b/TrueLove.UWP/Views/ImagesPage.xaml.cs index a23f619..524ac7f 100644 --- a/TrueLove.UWP/Views/ImagesPage.xaml.cs +++ b/TrueLove.UWP/Views/ImagesPage.xaml.cs @@ -5,6 +5,7 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media.Imaging; +using Windows.UI.Xaml.Navigation; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -23,6 +24,11 @@ public ImagesPage() DataLoad(); } + protected override void OnNavigatedFrom(NavigationEventArgs e) + { + Window.Current.Activated -= OnWindowActivated; + } + /// /// 返回顶部按钮。 ///