Change language

.NET Community Toolkit 8.0 Announced

The .NET Community Toolkit is a collection of helper classes and APIs that all .NET developers can use and that are independent of a particular UI platform.

See also: best laptop for development review

The Toolkit is maintained and published by Microsoft and is part of the .NET Foundation.

The .NET Community Toolkit is the successor to the Windows Community Toolkit. The developers explain its appearance as follows: over time, the number of API libraries using .NET and not designed to work with Windows has grown. Therefore, the decision was made to separate the project in order to be able to develop independently and be available to non-Windows .NET developers.

Since the last version of the Windows Community Toolkit before the new project was spun off was 7.1.x, it was decided to designate the first release of the .NET Community Toolkit as 8.0.0. In the future, both projects will be developed and versioned independently.

Libraries included in the .NET Community Toolkit:
CommunityToolkit.Common

CommunityToolkit.Mvvm (aka “Microsoft MVVM Toolkit”)

CommunityToolkit.Diagnostics

CommunityToolkit.HighPerformance

One of the most important components of the Toolkit is the MVVM Toolkit. It is based on MVVMLight, a previously extremely popular library for developing applications using the MVVM pattern (currently not supported). For those who still use MVVMLight, there is a plan to migrate to the Microsoft MVVM Toolkit.

In a nutshell, about the new features in version 8.0.0 in terms of the MVVM Toolkit.

An intensive use of source generators is announced, which will reduce the amount of boilerplate code.

When declaring and implementing Commands

Before:

private IRelayCommand<User> greetUserCommand;

public IRelayCommand<User> GreetUserCommand => greetUserCommand ??= new RelayCommand<User>(GreetUser);

private void GreetUser(User user)
{
    Console.WriteLine($"Hello {user.Name}!");
}

After:

[RelayCommand]
private void GreetUser(User user)
{
    Console.WriteLine($"Hello {user.Name}!");
}


When declaring and implementing Observable properties

Before:

private string? firstName;

public string? FirstName
{
    get => firstName;
    set
    {
        if (SetProperty(ref firstName, value))
        {
            OnPropertyChanged(nameof(FullName));
            GreetUserCommand.NotifyCanExecuteChanged();
        }
    }
}

private string? lastName;

public string? LastName
{
    get => lastName;
    set
    {
        if (SetProperty(ref lastName, value))
        {
            OnPropertyChanged(nameof(FullName));
            GreetUserCommand.NotifyCanExecuteChanged();
        }
    }
}

public string? FullName => $"{FirstName} {LastName}";

After:

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(FullName))]
[NotifyCanExecuteChangedFor(nameof(GreetUserCommand))]
private string? firstName;

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(FullName))]
[NotifyCanExecuteChangedFor(nameof(GreetUserCommand))]
private string? lastName;

public string? FullName => $"{FirstName} {LastName}";

Link to original announcement: https://devblogs.microsoft.com/dotnet/announcing-the-dotnet-community-toolkit-800/

Link to documentation: https://docs.microsoft.com/en-us/dotnet/communitytoolkit/

Link to the demo app in the Microsoft Store: https://apps.microsoft.com/store/detail/mvvm-toolkit-sample-app/9NKLCF1LVZ5H?hl=it-it&gl=IT

Author: Michael Zippo
2022/08/06

https://linkedin.com/in/michael-zippo-9136441b1
[email protected]

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

News


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method