Click here to Skip to main content
15,894,460 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my Windows Phone 8.1 app I'm creating a CustomPage and then navigating to it, all in code behind. My CustomPage class is:
using Windows.UI.Xaml.Controls;

namespace TestApp {
	public class CustomPage : Page {
		public CustomPage() {
			this.BuildPage();
		}

		private void BuildPage() {
			var panel = new StackPanel();
			panel.Children.Add(new TextBlock { Text = "Hello World" });
			this.Content = panel;
		}
	}
}

And then in my MainPage.xaml.cs I'm doing this:
CustomPage myNewPage = new CustomPage();
Frame.Navigate(myNewPage.GetType());

However this throws a System.TypeLoadException exception - Could not find Windows Runtime type 'Windows.Foundation'
If I don't do a CustomPage class just a Page class, it works fine, but I need to create a CustomPage class, how could I solve this?
Posted
Comments
Krimog 31-Mar-15 5:05am    
Hi, I've got the same exception. Did you somehow find a solution?

1 solution

You can use typeOf operator for getting the type of your custome page like below.

C#
typeof(myNewPage);
 
Share this answer
 
v2
Comments
Schrodinger's Box 6-Oct-14 6:42am    
That still throws the exception.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900