Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get the BooksViewModel via the DI container scope
public sealed partial class BooksPage : Page
private IServiceScope _scope;
public BooksPage()
_scope = AppServices.Instance.ServiceProvider.CreateScope();
Unloaded += (sender, e) => _scope.Dispose();
ViewModel = _scope.ServiceProvider.GetRequiredService<BooksViewModel>();
public BooksViewModel ViewModel { get; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment