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

[Feature] Microsoft.Toolkit.Mvvm package (Preview 4) #3527

Merged
24 commits merged into from
Nov 11, 2020

Conversation

Sergio0694
Copy link
Member

Follow up to #3428

This PR is for tracking all changes/fixes/improvements to the Microsoft.Toolkit.Mvvm package following the Preview 3.

PR Type

What kind of change does this PR introduce?

  • Feature
  • Improvements

Overview

This PR is used to track and implement new features and tweaks for the Microsoft.Toolkit.Mvvm package.
See the linked issue for more info, and for a full list of changes included in this PR.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Pull Request has been submitted to the documentation repository instructions. Link:
  • Sample in sample app has been added / updated (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

@Sergio0694 Sergio0694 added feature 💡 improvements ✨ optimization ☄ Performance or memory usage improvements .NET Components which are .NET based (non UWP specific) mvvm-toolkit 🧰 Issues/PRs for the Microsoft.Toolkit.Mvvm package labels Oct 7, 2020
@Sergio0694 Sergio0694 added this to the 7.0 milestone Oct 7, 2020
@ghost
Copy link

ghost commented Oct 7, 2020

Thanks Sergio0694 for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@ghost ghost requested review from michael-hawker, azchohfi and Kyaa-dost October 7, 2020 10:38
@Sergio0694 Sergio0694 linked an issue Oct 7, 2020 that may be closed by this pull request
27 tasks
@sonnemaf
Copy link
Contributor

Hi @Sergio0694,

I just noticed that the RelayCommand is a SEALED class. Why? I would love to derive from it. I would love to create something like a LabeledRelayCommand like this.

public class LabeledRelayCommand : RelayCommand, ILabeledCommand {

    public LabeledRelayCommand(Label label, Action execute) : this(label, execute, null) {
    }

    public LabeledRelayCommand(Label label, Action execute, Func<bool> canExecute) : base(execute, canExecute) {
        this.Label = label ?? throw new ArgumentNullException(nameof(label));
    }

    public Label Label { get; }
}

@Sergio0694
Copy link
Member Author

Hey @sonnemaf - they're sealed because each command is not really meant to be extended in functionality, both due to how they're internally structured (eg. the AsyncRelayCommand with all the various fields and logic to handle cancellation etc.) and because we figured the main reason why devs would want to extend them would be, like in your case, just to add some extra properties that are unrelated to the actual commanding logic. In this case extending them would not really be ideal, especially because if you also wanted to have the same extra properties in other commands, you'd need to extend every single one of them and add the same property every time. For cases such as this I think the best approach is to use a type like StandardUICommand (from WinUI, here), which is meant to be used exactly in these situations. It has the advantage of having a number of extra properties built in, and it's meant to just bind to some ICommand, which means you can use it with all the 4 existing commands in the MVVM Toolkit without having to subclass any of them. Would this solve the issue in your situation? 😄

@sonnemaf
Copy link
Contributor

@Sergio0694 Thank you for this explanation. This makes sense I will use the containment solution you suggested.

@Sergio0694
Copy link
Member Author

Awesome, glad I could help! 😊

@michael-hawker michael-hawker added the next preview ✈️ Label for marking what we want to include in the next preview release for developers to try. label Nov 5, 2020
@Sergio0694 Sergio0694 marked this pull request as ready for review November 11, 2020 17:58
@ghost
Copy link

ghost commented Nov 11, 2020

Hello @michael-hawker!

Because this pull request has the auto merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto merge ⚡ feature 💡 improvements ✨ mvvm-toolkit 🧰 Issues/PRs for the Microsoft.Toolkit.Mvvm package .NET Components which are .NET based (non UWP specific) next preview ✈️ Label for marking what we want to include in the next preview release for developers to try. optimization ☄ Performance or memory usage improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Microsoft.Toolkit.Mvvm package (Preview 5)
4 participants