Skip to content

Instantly share code, notes, and snippets.

View dhindrik's full-sized avatar
😎
Writing code!

Daniel Hindrikes dhindrik

😎
Writing code!
View GitHub Profile
// Option 1
foreach (var viewModel in assembly.DefinedTypes.Where(e => e.IsSubclassOf(typeof(ViewModel))))
{
builder.Services.AddTransient(viewModel.GetType());
}
foreach (var view in assembly.DefinedTypes.Where(e => e.IsSubclassOf(typeof(Views.View))))
{
builder.Services.AddTransient(view.GetType());
}
public partial class MainPage : ContentPage
{
private MainPageViewModel ViewModel => BindingContext as MainPageViewModel;
public MainPage(MainPageViewModel viewModel)
{
InitializeComponent();
BindingContext = viewModel;