From 5c0e323540e492789f5bb1aeba8d59fd8778bd52 Mon Sep 17 00:00:00 2001 From: Shalini-Ashokan <102292178+Shalini-Ashokan@users.noreply.github.com> Date: Thu, 26 Mar 2026 13:46:30 +0530 Subject: [PATCH] Fixed the IsEnabled back button failures --- .../src/Core/Shell/BackButtonBehavior.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Controls/src/Core/Shell/BackButtonBehavior.cs b/src/Controls/src/Core/Shell/BackButtonBehavior.cs index d3d3f1e85278..5e9b062fc730 100644 --- a/src/Controls/src/Core/Shell/BackButtonBehavior.cs +++ b/src/Controls/src/Core/Shell/BackButtonBehavior.cs @@ -62,13 +62,22 @@ public ImageSource IconOverride set { SetValue(IconOverrideProperty, value); } } + // Tracks the value explicitly set by the user (default matches IsEnabledProperty default of true). + bool _userDefinedIsEnabled = true; + // Tracks the enabled state derived from the command's CanExecute result. + bool _commandEnabled = true; + /// /// Gets or sets a value indicating whether the back button is enabled. This is a bindable property. /// public bool IsEnabled { get { return (bool)GetValue(IsEnabledProperty); } - set { SetValue(IsEnabledProperty, value); } + set + { + _userDefinedIsEnabled = value; + SetValue(IsEnabledProperty, _userDefinedIsEnabled && _commandEnabled); + } } /// @@ -89,7 +98,14 @@ public string TextOverride set { SetValue(TextOverrideProperty, value); } } - bool IsEnabledCore { set => SetValue(IsEnabledProperty, value && IsEnabled); } + bool IsEnabledCore + { + set + { + _commandEnabled = value; + SetValue(IsEnabledProperty, _userDefinedIsEnabled && value); + } + } static void OnCommandChanged(BindableObject bindable, object oldValue, object newValue) {