From 5a1bb218e1c06adb543e3a403d649b15ae4cdf1c Mon Sep 17 00:00:00 2001 From: James Crutchley Date: Mon, 23 Feb 2026 14:22:35 -0800 Subject: [PATCH] Remove duplicated event and move behavior to the same event in another class that is released when dispose is called. I see no need for two events that handle the same event. I should never have had two to start with. This fixes that. --- .../CustomTransportControls.windows.cs | 16 ---------------- .../Views/MauiMediaElement.windows.cs | 2 ++ 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/CommunityToolkit.Maui.MediaElement/Primitives/CustomTransportControls.windows.cs b/src/CommunityToolkit.Maui.MediaElement/Primitives/CustomTransportControls.windows.cs index 9df28c6d04..ef64d5d01b 100644 --- a/src/CommunityToolkit.Maui.MediaElement/Primitives/CustomTransportControls.windows.cs +++ b/src/CommunityToolkit.Maui.MediaElement/Primitives/CustomTransportControls.windows.cs @@ -6,7 +6,6 @@ sealed partial class CustomTransportControls : MediaTransportControls { public event EventHandler? OnTemplateLoaded; public AppBarButton FullScreenButton = new(); - bool isFullScreen = false; public CustomTransportControls() { @@ -22,21 +21,6 @@ protected override void OnApplyTemplate() FullScreenButton = appBarButton; FullScreenButton.Visibility = Microsoft.UI.Xaml.Visibility.Visible; OnTemplateLoaded?.Invoke(this, EventArgs.Empty); - FullScreenButton.Click += FullScreenButton_Click; - } - } - - void FullScreenButton_Click(object sender, RoutedEventArgs e) - { - if (isFullScreen) - { - FullScreenButton.Icon = new FontIcon { Glyph = "\uE740" }; - isFullScreen = false; - } - else - { - FullScreenButton.Icon = new SymbolIcon(Symbol.BackToWindow); - isFullScreen = true; } } } \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs b/src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs index 3ca4b23d6b..497835e4d0 100644 --- a/src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs +++ b/src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs @@ -195,6 +195,7 @@ void OnFullScreenButtonClick(object sender, RoutedEventArgs e) var parent = mediaPlayerElement.Parent as FrameworkElement; mediaPlayerElement.Width = parent?.Width ?? mediaPlayerElement.Width; mediaPlayerElement.Height = parent?.Height ?? mediaPlayerElement.Height; + customTransportControls?.FullScreenButton.Icon = new FontIcon { Glyph = "\uE740" }; } else { @@ -221,6 +222,7 @@ void OnFullScreenButtonClick(object sender, RoutedEventArgs e) { popup.IsOpen = true; } + customTransportControls?.FullScreenButton.Icon = new SymbolIcon(Symbol.BackToWindow); } } } \ No newline at end of file