Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UWP Support: Add ScarletCommandManager that doesnt rely on WPFs CommandManager #16

Open
mastorm opened this issue Jan 29, 2020 · 2 comments
Assignees
Milestone

Comments

@mastorm
Copy link

mastorm commented Jan 29, 2020

Microsoft removed the CommandManager in UWP.

public sealed class ScarletCommandManager : IScarletCommandManager

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

@Insire Insire self-assigned this Jan 29, 2020
@Insire Insire added this to the Release 3.0 milestone Jan 29, 2020
@Insire
Copy link
Owner

Insire commented Jan 29, 2020

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);
        }
    }

@mastorm
Copy link
Author

mastorm commented Jan 29, 2020

Will test this in my app too, gonna add it here if i notice a rough edge or something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants