Skip to content

Create ViewModels and navigation

Jeppe Roi Kristensen edited this page Mar 11, 2025 · 1 revision

Supported Xaml platforms

The following platforms are allowed to create a view model

  • WPF
  • Avalonia
  • MAUI
  • WINUI

Creating view models

With the exception of WinUI when creating a view model for a view a type attribute will be added to the xaml view to "link" the two.

For instance for WPF it will be through a d:DataContext attribute and in Avalonia and Maui it will be through the x:DataType attribute.

For WinUI where the view model is typically not declared in the xaml view, it will be set directly in the code behind instead.

public SomeViewModel ViewModel {get;set;}

Navigating between view and viewModel

I

Clone this wiki locally