0

My Project:

  • MyAppB (External Shared Project)

    • includes multiple views (xaml files) which extends from ContentPage
    • uses e.g. await Navigation.PushAsync(new Chat());
  • MyApplicationA (Code Sharing - .NET Standard 2.0)

    • is build with prism framework (Model-View-ViewModel)
    • uses e.g. await NavigationService.NavigateAsync("name", parameters);
  • MyApplicationA.Android

    • references both (MyApplicationA and MyAppB) -> Is this correct?
  • MyApplicationA.iOS

    • references both (MyApplicationA and MyAppB) -> Is this correct?

My Goal: I want to navigate from a view or viewmodel in MyApplicationA to a view in MyAppB.

Fortunatly navigating to a view in MyAppB from a viewmodel in MyApplicationA is working.

I'm using a interface definition in MyApplicationA and calls it in the viewmodel. The interface is implemented in the MyApplicationA.Android and MyApplicationA.iOS.

WORKS: To navigate i use: App.Current.MainPage = new NavigationPage(new MainPage(screenCaptureIntent)); // (the intent is the reason why i have to navigate from MyApplicationA to MyApplicationA.Android and then to MyAppB)

DONT WORK: Using await App.Current.MainPage.Navigation.PushAsync(new MainPage(screenCaptureIntent)); is not working and gives the following error: PushAsync is not supported globally on Android, please use a NavigationPage.

But i have problems to go back from the view in MyAppB to the application in MyApplicationA e.g. a view which loads data, in best case it would be the last page in the navigation stack...

Does someone have a hint for me how to solve this? Am I doing it the right way? Or can i reference MyAppB in MyApplicationA - but what happens to the device specific code e.g. #if __IOS__

Thx Daniel

Daniel0b1b
  • 2,271
  • 2
  • 11
  • 9
  • Why does `MyAppB` not use the `NavigationService`? – Haukinger Jun 17 '19 at 11:14
  • there is a bug while navigating. If we fix it, it will work. –  Jun 17 '19 at 11:32
  • @Haukinger can it? How does it know which PageName exists in MyApplicationA, they are registered with containerRegistry.RegisterForNavigation(); in App.xaml.cs in MyApplicationA – Daniel0b1b Jun 17 '19 at 15:32
  • If MyApplicationA references MyAppB, you will be able to register the views in the same way you are registering the views for MyApplicationA. The platform specific projects can reference MyApplicationA and get the implicit reference to MyAppB. `#if __IOS__` directives will still work, those look at constants defined when building for iOS and Android. – Max Hampton Jun 17 '19 at 16:55
  • @MaxHampton referencing MyAppB in MyApplicationA is not an option, MyAppB is an implementation of IceLink SDK and the platform specific projects needs seperate dlls included to work. This doesnt look to work with an implicit reference – Daniel0b1b Jun 18 '19 at 06:03
  • @Daniel0b1b for sure, either directly or - more likely - indirectly through another service provided to `MyAppB` by `MyApplicationA`. – Haukinger Jun 18 '19 at 08:50
  • In PrismApplication, there is an overloaded constructor that takes an IPlatformInitializer argument. In each platform project you can implement this interface, and pass it in when you call LoadApplication(new App()) in MainActivity and AppDelegate in the platform projects. That interface has 1 method, RegisterTypes, where you can register platform specifics with the IoC container in the same way you do in App.xaml.cs – Max Hampton Jun 18 '19 at 16:34

0 Answers0