Skip to content

Commit

Permalink
Delay first execution of ICommand.CanExecute(object parameter) until …
Browse files Browse the repository at this point in the history
…after initialization. Issue #316

Revert changes to Hyperlink.cs
  • Loading branch information
MichaelVach committed Jul 5, 2019
1 parent 33df9e1 commit 0c6b967
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ private static void PrivateRegisterCommandHandler(Type controlType, RoutedComman

internal static bool CanExecuteCommandSource(ICommandSource commandSource)
{
if (commandSource is FrameworkElement fe)
{
if (!fe.IsInitialized)
{
return false;
}
}

ICommand command = commandSource.Command;
if (command != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,7 @@ protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutoma
/// </summary>
protected override void OnInitialized(EventArgs e)
{
UpdateCanExecute();
base.OnInitialized(e);
UpdateRole();
#if OLD_AUTOMATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ private void UpdateCanExecute()
}
}

protected override void OnInitialized(EventArgs e)
{
UpdateCanExecute();
base.OnInitialized(e);
}

/// <summary>
/// Fetches the value of the IsEnabled property
/// </summary>
Expand Down

0 comments on commit 0c6b967

Please sign in to comment.