Created
March 21, 2013 16:54
-
-
Save pedroreys/5214612 to your computer and use it in GitHub Desktop.
WP8 NavigationService::Navigate only takes an URI as an argument. It will then throw if you try to navigate to a view that has ctor dependencies. Call on line 14 of Welcome.xaml.cs will throw.
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
public partial class Login : PhoneApplicationPage | |
{ | |
ILoginService _service; | |
public Login(ILoginService service) | |
{ | |
this.InitializeComponent(); | |
_service = service; | |
} | |
//do whatever here that uses ILoginService | |
} |
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
public partial class Welcome : PhoneApplicationPage | |
{ | |
public Welcome() | |
{ | |
this.InitializeComponent(); | |
} | |
private void GetStartedButton_Click(object sender, RoutedEventArgs e) | |
{ | |
} | |
private void LoginButton_Click(object sender, RoutedEventArgs e) | |
{ | |
this.NavigationService.Navigate(new Uri("/Views/Login.xaml", UriKind.Relative)); | |
// This call will throw because Login.xaml doesn't have a parameterless constructor | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment