-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2523 from MahApps/2485-Flyout-improvement
flyout improvement caused by #2485
- Loading branch information
Showing
11 changed files
with
196 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.Windows.Input; | ||
|
||
namespace MahApps.Metro.Controls | ||
{ | ||
internal class CloseCommand : ICommand | ||
{ | ||
private readonly Func<object, bool> canExecute; | ||
private readonly Action<object> executeAction; | ||
|
||
public CloseCommand(Func<object, bool> canExecute, Action<object> executeAction) | ||
{ | ||
this.canExecute = canExecute; | ||
this.executeAction = executeAction; | ||
} | ||
|
||
/// <summary> | ||
/// Defines the method that determines whether the command can execute in its current state. | ||
/// </summary> | ||
/// <returns> | ||
/// true if this command can be executed; otherwise, false. | ||
/// </returns> | ||
/// <param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to null.</param> | ||
public bool CanExecute(object parameter) | ||
{ | ||
return this.canExecute != null && this.canExecute(parameter); | ||
} | ||
|
||
/// <summary> | ||
/// Defines the method to be called when the command is invoked. | ||
/// </summary> | ||
/// <param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to null.</param> | ||
public void Execute(object parameter) | ||
{ | ||
this.executeAction?.Invoke(parameter); | ||
} | ||
|
||
public event EventHandler CanExecuteChanged | ||
{ | ||
add { CommandManager.RequerySuggested += value; } | ||
remove { CommandManager.RequerySuggested -= value; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.