Skip to content

Latest commit

 

History

History
85 lines (60 loc) · 2.29 KB

README.md

File metadata and controls

85 lines (60 loc) · 2.29 KB

abp-wpf

An abp.io BookStore sample including a more complete wpf example using mvvm source generators and a slick UI 😍

🎩 Features

💻 Screenshot

example

Interesting Bits

Source Generators

This app utilizes the CommunityToolkit.Mvvm source generators details.

This makes it so we can cut loads of boilerplate out like this:

In BookIndexViewModel.cs

[RelayCommand]
public async Task InitialAsync()
{
    await LoadDataAsync();
}

In BookIndex.xaml

<Behaviors:InvokeCommandAction Command="{Binding InitialCommand}"/>

The source generators take care of generating the command property and setting it up (what you would normally do in the constructor).

You can even handle the CanExecute simply:

public bool GetIsNotBusy() => IsNotBusy;

[RelayCommand(CanExecute = "GetIsNotBusy", AllowConcurrentExecutions = true)]
public async Task InitialAsync()
{
    await LoadDataAsync();
}

Note: As of right now, the CanExecute of the source generator can't seem to see the base property of IsNotBusy so this is a simple workaround.

Abp Localization in the XAML

AppViewModel exposes the Abp l18n via L so you can use it in the xaml like this:

<wpfui:NavigationItem
    Content="{Binding Path=L[Books]}" />

Where Books is the l18n key:

{
  "culture": "en",
  "texts": {
    "Menu:Home": "Home",
    "Welcome": "Welcome",
    "LongWelcomeMessage": "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io.",
    "Books": "BoOkS"
  }
}

WPF Test Project

Check out the project Acme.BookStore.Wpf.Tests which is an adaptation of the Web tests specifically for testing the view models.

BookStore Sample