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)
{