Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/Controls/src/Core/Shell/BackButtonBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
/// Gets or sets a value indicating whether the back button is enabled. This is a bindable property.
/// </summary>
public bool IsEnabled
{
get { return (bool)GetValue(IsEnabledProperty); }
set { SetValue(IsEnabledProperty, value); }
set
{
_userDefinedIsEnabled = value;
SetValue(IsEnabledProperty, _userDefinedIsEnabled && _commandEnabled);
}
}

/// <summary>
Expand All @@ -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)
{
Expand Down
Loading