WPF and MVVM
Target net8.0-windows with <UseWPF>true</UseWPF>. XAML for views, VB for code-behind and view models.
MVVM: View (XAML) ↔ ViewModel (INotifyPropertyChanged, ICommand) ↔ Model/services. Binding modes (OneWay, TwoWay, OneTime), UpdateSourceTrigger, value converters, validation (INotifyDataErrorInfo), data templates, styles and resource dictionaries, control templates, triggers, ObservableCollection(Of T), CollectionViewSource (sorting, filtering, grouping), dependency properties and attached properties, routed events/commands, Dispatcher, animations, and themes.
CommunityToolkit.Mvvm base classes (ObservableObject, RelayCommand, AsyncRelayCommand, WeakReferenceMessenger) are usable from VB. Its source generators (<ObservableProperty>) are C#-only.
Alternatives for new cross-platform UIs: Avalonia (VB possible with setup), or a C# UI over VB libraries.
Public Class CustomersViewModel
Inherits ObservableObject ' your base class or CommunityToolkit.Mvvm.ComponentModel.ObservableObject
Private ReadOnly _service As ICustomerService
Public ReadOnly Property Customers As New ObservableCollection(Of Customer)
Private _selected As Customer
Public Property Selected As Customer
Get
Return _selected
End Get
Set(value As Customer)
SetProperty(_selected, value)
End Set
End Property
Public ReadOnly Property LoadCommand As IAsyncRelayCommand
Public Sub New(service As ICustomerService)
_service = service
LoadCommand = New AsyncRelayCommand(AddressOf LoadAsync)
End Sub
Private Async Function LoadAsync() As Task
Customers.Clear()
For Each c In Await _service.GetAllAsync()
Customers.Add(c)
Next
End Function
End Class