c# - Prism for Xamarin, dependency failed for INavigationService -


i working on sample xamarin.forms app ios, using prism.

but when tried use inavigationservice in viewmodel, failed saying dependency failed interface inavigationservice

i dont know wrong doing, how can around or bug in inavigationservices injection.

thanks divikiran ravela

heres code

    public app()     {         // root page of application         prism = new prismbootstrap();         prism.run(this);     }      public class prismbootstrap : unitybootstrapper {     protected override page createmainpage()     {         return new navigationpage(container.resolve<homepage>());     }      protected override void registertypes()     {         container.registertypefornavigation<homepage, homepageviewmodel>();     } }       public class homepage : contentpage     {          public homepageviewmodel viewmodel { get; set; }      public homepage()     {         viewmodel = app.prism.container.resolve<homepageviewmodel>();         content = new stacklayout         {             children = {                 new label { text = "hello contentpage" }             }         };     } }   public class homepageviewmodel : bindablebase {     private readonly inavigationservice _navigationservice;      public homepageviewmodel(inavigationservice navigationservice)     {         _navigationservice = navigationservice; //fails here     } } 

the inavigationservice depends on use of viewmodellocator. if don't use it, service cannot injected. instead of manually resolving vm, use viewmodellocator.autowireviewmodel attached property. besides, don't want using container that. want 1 composition root when using di.

also, recommend using latest 6.1 preview. has ton of navigation improvements.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -