Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stevemonaco/avaloniaviewmodelfirstdemos

Demonstrates ViewModel-First MVVM scenarios with Avalonia
https://github.com/stevemonaco/avaloniaviewmodelfirstdemos

Last synced: 9 days ago
JSON representation

Demonstrates ViewModel-First MVVM scenarios with Avalonia

Awesome Lists containing this project

README

        

# AvaloniaViewModelFirstDemos

Various demos that use ViewModel-First MVVM in Avalonia. This means that the ViewModel is always created first and the View is resolved/created based on the ViewModel's type or shape. Approaches typically include some combination of a ViewLocator, `ContentControl`s, and `DataTemplate`s.

## AOT-friendly ViewLocators

Currently, these demos have equal functionality, but have different technical implementations. Service registration for dependency injection has traditionally been reflection-heavy, and these demos show newer source generator approaches to eliminate that problem. This opens up trimming and Ahead-Of-Time compilation support while keeping ViewModel-First support with ViewLocator. The ViewLocator could be enhanced for broader view-caching or alternatively skipped altogether to instead define every ViewModel -> View mapping as a `DataTemplate` in XAML.

![Demo Screenshot](AvaloniaCommunityToolkitAot/DemoImages/Screenshot.png)

### AvaloniaCommunityToolkitAot

Demonstrates how to use the lab preview of [CommunityToolkit.Extensions.DependencyInjection](https://github.com/CommunityToolkit/Labs-Windows/discussions/463) with `Microsoft.Extensions.DependencyInjection` to create an AOT-friendly ViewLocator.

This package currently requires the [Toolkit Labs preview feed](https://github.com/CommunityToolkit/WindowsCommunityToolkit/wiki/Preview-Packages#toolkit-labs-)

### AvaloniaJabAot

Demonstrates how to use [Jab](https://github.com/pakrym/jab) to create an AOT-friendly ViewLocator.