Giter Club home page Giter Club logo

mauiapp-di's Introduction

MauiApp-DI

Shows DI/IoC for app, page, and view model.

Checkout my YouTube videos on .NET MAUI!

Note: That [ICommand] is now [RelayCommand] from the .NET community toolkit!

mauiapp-di's People

Contributors

jamesmontemagno avatar brianobr avatar

Stargazers

Meysam Savameri avatar Rod P avatar Nader Elshehabi avatar Ryan Christensen avatar Andrew avatar JackyHuang avatar Vladimir avatar  avatar  avatar  avatar PPPYGKKMRMT avatar Jacob Campbell avatar Soar avatar Mike van Nieuwburg avatar  avatar BlueSharkPartners avatar Evgeny avatar Sechaba Motaung avatar  avatar Nikos Mpasdanis avatar Eric Williams avatar  avatar Denis Prokhorchik  avatar .NET MAUI HighSchool avatar Media Explorer avatar  avatar Mahmoud Kinawy avatar  avatar  avatar  avatar Herbert Nijkamp avatar  avatar Patrick Morris avatar duong.nb avatar Daniel Monettelli avatar Missy Maloney avatar  avatar Stuart Wright avatar Rafael Evaristo avatar Azhe Kun avatar Unix Doughnut avatar Alex Billson avatar I"s avatar Claus Rogisch avatar Lucian Naie avatar Alexandre Sanlim avatar Konstantsin Demedenkov avatar Kevin Xu avatar Marcin Nowacki avatar Brian Reville avatar Oliver Valiente avatar Stephan Kieburg avatar Csaba Huszar avatar  avatar  avatar  avatar Balázs SZAKÁLY avatar Anass Ayed avatar Cédric Couliou avatar Timothy Huber avatar Sheharyar Shahid avatar Russ Hardie avatar Alex avatar Mohsen Saniee (MS2) avatar Vicente Guzmán avatar Naji El Kotob avatar Brice Friha avatar

Watchers

Cédric Couliou avatar James Cloos avatar  avatar  avatar  avatar Balázs SZAKÁLY avatar  avatar Claus Rogisch avatar

mauiapp-di's Issues

Can't get navigation to work

I am getting really frustrated with MAUI - every time I come back to it, it is the same thing - following example code and it does not work :-(

So I have a button on a page and a command then when on clicked does await Shell.Current.GoToAsync( nameof( NewCoursePage ) ); However, that generates the following exception:

image

I have registered my View and ViewModel with the Service container:

        builder.Services.AddTransient<NewCoursePage>();
        builder.Services.AddTransient<NewCoursePageViewModel>();

I have also registered the route:

Routing.RegisterRoute( nameof( NewCoursePage ), typeof( NewCoursePageViewModel ) ); 

Looking at the exception it would seem to be something to do with passing the view model to the view (I use constructor injection of the view model into the view) but I can't see anything different in the code in this repo to my code.

Does anyone have an idea what I am doing wrong?

Andy

Two way binding entry not working

Hi James,

I'd like to test a TwoWay binding on an entry so I added this code to the grid of your MainPage.xaml:

            <Entry 
                Grid.Row="5"
                FontSize="18"
                HeightRequest="40"
                Text="{Binding Count, Mode=TwoWay}"
                HorizontalOptions="Center" />

When I change the value in the entry, I expect to see a call to the Count setter but nothing happens.
What am I doing wrong?

Why when you register service for IConnectivy you pass as argument an specific implementation?

When you register the services for IConnectivity, you use this code:

builder.Services.AddSingleton<IConnectivity>((e) => Connectivity.Current);

If I don't understand wrong, it means that when IConnectivity is requested, it is passeed Connectivity.Current, that is a specific implementation of IConnectivity. So it is not possible to pass another implementation.

So my cuestion is, if I have an own implementation of IConnectivity, how could I decide to use the Connectivity.Current or my own implementation?

Perhaps with the connectivity it has not too much sense, but I am thinking in general and for example in unit tests, in which I could be interested in using my own imlpementantion.

Thanks.

Disposal Question

When using dependency injection, how do you ensure that any injected service that implements IDisposable is property disposed on application shutdown?

I am learning Maui, have a background in WPF. In WPF, you could dispose on an IHost instance in the App.xaml.cs OnExit method to ensure that all disposable resources are disposed.

I have not seen any documentation for anything like this for Maui.

Thanks. Great youtube video.

the example is great however cannot figure out how to DI with library modules and MAUI

Example:
Want to extend what you have done and create following clean architecture layers
a. Domain (MAUI Class Library)
b. Data (MAUI Class Library)

Can you explain how to get the parent App to consume Domain
and Domain library to consume Data layer interfaces.

your MauiProgram.cs file registers services for view model

You do I register the domain and data layre services so they can be used across the layers correctly.

appreciate your guidance

Permission Bluetooth Maui for Android

for the Bluetooth permission in an Android; is there a way to activate automatically in the start of the Maui app without passing on the button to activate the Bluetooth.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.