Created
July 1, 2020 14:31
-
-
Save nodoid/1ac1aad465626ff1901a38d1d8c22507 to your computer and use it in GitHub Desktop.
Passing an interface in Shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I fire up my forms app with the following | |
(From https://github.com/CrossGeeks/SocialMediaAuthenticationSample - the services etc are implemented on the platform) | |
LoadApplication(new App(new OAuth2Service())); | |
My app.xaml.cs looks like this | |
public App(IOAuth2Service oAuth2Service) | |
{ | |
// stuff | |
MainPage = new AppShell(); | |
Shell.Current.GoToAsync($"//Login?Auth={oAuth2Service}"); | |
} | |
I have in my AppShell.xaml the following | |
<ShellItem Route="Login"> | |
<ShellContent ContentTemplate="{DataTemplate local:LoginPage}" /> | |
</ShellItem> | |
And finally in my LoginPage | |
IOAuth2Service auth; | |
public IOAuth2Service Auth | |
{ | |
get => auth; | |
set | |
{ | |
auth = value; | |
OnPropertyChanged(); | |
} | |
} | |
When I run the app and check the Auth property, it's null. | |
Do I need to remove this route from AppShell.xaml or is there something I'm missing? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment