Reputation: 2623
Basically, what i have is one solution with two projects targeting Windows Phone 7 and Windows Phone 8. I have linked the pages and classes from my WP7 project to WP8 project (add as link), also each project contains two separate pages TestPage.xaml
and TestPageWP8.xaml
.
In the WP8 project i have added additional Conditional compilation symbols
WP8. So in my MainPage i have something like:
private void onButtonClick(object sender, RoutedEventArgs e)
{
#if WP8
NavigationService.Navigate(new Uri("/TestPageWP8.xaml", UriKind.Relative));
#else
NavigationService.Navigate(new Uri("/TestPage.xaml", UriKind.Relative));
#endif
}
The problem is that i can not open TestPageWP8
, the application always opens TestPage
My StartUp Project is WP7, i have Nokia Lumia 920 and 610. I am missing something but what?
Thank you!
Upvotes: 0
Views: 281
Reputation: 3683
Using this example code from MangoPollo library, you can make your own SpeechSynthesizer
library
Type taskDataType = Type.GetType("Microsoft.Phone.Tasks.MapsTask, Microsoft.Phone");
object task = taskDataType.GetConstructor(new Type[] {}).Invoke(null);
Utils.SetProperty(task, "SearchTerm", SearchTerm);
if (ZoomLevel > 0)
Utils.SetProperty(task, "ZoomLevel", ZoomLevel);
Utils.SetProperty(task, "Center", Center);
MethodInfo showmethod = taskDataType.GetMethod("Show");
showmethod.Invoke(task, new object[] {});
Upvotes: 1
Reputation: 10620
If you have as a startup project the WP7 version, then the "WP8" compilation symbol is not defined in this solution and you'll navigate to the TestPage.xaml.
If you want to navigate to TestPageWP8.xaml, you need to set as the startup project the WP8 project.
Also make sure the compilation symbol WP8 is actually defined in your WP8 project - right click the project, go to Properties and check the Build tab, if WP8 is defined next to the "SILVERLIGHT;WINDOWS_PHONE" symbols.
Upvotes: 1
Reputation: 641
Try this code:
if (Environment.OSVersion.Version >= new Version(8, 0))
{
NavigationService.Navigate(new Uri("/TestPageWP8.xaml", UriKind.Relative));
}
else
{
NavigationService.Navigate(new Uri("/TestPage.xaml", UriKind.Relative));
}
Upvotes: 1
Reputation: 39037
Well, if it navigates to TestPage
, it means either that the conditional compilation symbol wasn't properly defined, or that you're running the WP7 version of the app... Which seems to be the case since your startup project is the WP7 version.
Upvotes: 1