Skip to content

Instantly share code, notes, and snippets.

@pedroreys
Created March 21, 2013 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedroreys/5214612 to your computer and use it in GitHub Desktop.
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.
public partial class Login : PhoneApplicationPage
{
ILoginService _service;
public Login(ILoginService service)
{
this.InitializeComponent();
_service = service;
}
//do whatever here that uses ILoginService
}
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