MvvmScarletToolkit
MvvmScarletToolkit copied to clipboard
UWP Support: Add ScarletCommandManager that doesnt rely on WPFs CommandManager
Microsoft removed the CommandManager in UWP.
https://github.com/Insire/MvvmScarletToolkit/blob/216c0b93361f94f344268fd5f084fbcb4d466086/src/MvvmScarletToolkit.Implementations/ScarletCommandManager.cs#L10
The current implementation relies on CommandManager. The fix is pretty easy, since you already abstracted it away behind an IScarletCommandManager
Something like this COULD do the job(needs re-evaluation by somebody more experienced than me):
public sealed class UwpScarletCommandManager : IScarletCommandManager
{
private static readonly Lazy<UwpScarletCommandManager > _default = new Lazy<ScarletCommandManager>(() => new UwpScarletCommandManager ());
public static IScarletCommandManager Default { get; } = _default.Value;
public event EventHandler RequerySuggested { get; set; }
public void InvalidateRequerySuggested()
{
CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
}
This solution is basically from this stackoverflow thread: https://stackoverflow.com/questions/12030697/what-replaces-commandmanager-in-winrt
I've come up with this based on your link and little of my own googling. Gonna test it somewhen and add it to the repo after that.
public sealed class UwpScarletCommandManager : IScarletCommandManager
{
private static readonly Lazy<UwpScarletCommandManager> _default = new Lazy<UwpScarletCommandManager>(() => new UwpScarletCommandManager());
public static IScarletCommandManager Default { get; } = _default.Value;
public event EventHandler? RequerySuggested;
public void InvalidateRequerySuggested()
{
RequerySuggested?.Invoke(this, EventArgs.Empty);
}
}
Will test this in my app too, gonna add it here if i notice a rough edge or something