Xaml 无法创建类型为';Microsoft.Phone.Shell.PhoneApplicationService';[第38行位置:23]
在从一个页面重定向到另一个页面时,我遇到以下异常 无法创建“Microsoft.Phone.Shell.PhoneApplicationService”类型的实例[行:38位置:23] 第一页代码如下:Xaml 无法创建类型为';Microsoft.Phone.Shell.PhoneApplicationService';[第38行位置:23],xaml,windows-phone-8,navigation,instance,xamlparseexception,Xaml,Windows Phone 8,Navigation,Instance,Xamlparseexception,在从一个页面重定向到另一个页面时,我遇到以下异常 无法创建“Microsoft.Phone.Shell.PhoneApplicationService”类型的实例[行:38位置:23] 第一页代码如下: NavigationService.Source = (new Uri("/SecondPage.xaml?selectedItem=" + myId, UriKind.RelativeOrAbsolute)); 在上面uri的帮助下,我正在调用我的第二个页面。根据stackOverflow中
NavigationService.Source = (new Uri("/SecondPage.xaml?selectedItem=" + myId, UriKind.RelativeOrAbsolute));
在上面uri的帮助下,我正在调用我的第二个页面。根据stackOverflow中提供的一些解决方案,我在我的xaml页面中有一个问题,我正在将它粘贴到我的xaml页面代码下面
SupportedOrientations="PortraitOrLandscape"
shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded"
tools:TiltEffect.IsTiltEnabled="True" Orientation="Portrait" >
<phone:PhoneApplicationPage.Resources>
<shell:ApplicationBar x:Key="SettingsBar" IsVisible="True" Mode="Default">
<shell:ApplicationBarIconButton x:Name="btnHome" IconUri="Images/home.png" Text="home" Click="btnHome_Click" />
<shell:ApplicationBarIconButton x:Name="cot" IconUri="Images/toc.png" Text="toc" Click="btnToc_Click"/>
<shell:ApplicationBarIconButton x:Name="zoom" IconUri="Images/zoom.png" Text="zoom" Click="btnZoom_Click"/>
<shell:ApplicationBarIconButton x:Name="setting" IconUri="Images/settings.png" Text="settings" Click="btnSettings_Click" />
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem x:Name="SettingBar_wb" Click="AppMenu_wb_Click" Text="See Wordbank" />
<shell:ApplicationBarMenuItem x:Name="SettingBar_sn" Click="AppMenu_sn_Click" Text="See Notes, " />
<shell:ApplicationBarMenuItem x:Name="SettingBar_hight" Click="AppMenu_hight_Click" Text="See Highlight" />
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
<shell:ApplicationBar x:Key="AnnotatorBar" IsVisible="True" >
<shell:ApplicationBarIconButton x:Name="notes" IconUri="Images/notes.png" Text="note" Click="btnNote_Click" />
<shell:ApplicationBarIconButton x:Name="myhights" IconUri="Images/myghights.png" Text="highlight" Click="btnHighlight_Click"/>
<shell:ApplicationBarIconButton x:Name="definsed" IconUri="Images/definesed.png" Text="Define" Click="btnDefine_Click"/>
<shell:ApplicationBarIconButton x:Name="webs" IconUri="Images/webs.png" Text="wordbank" Click="btnWordbank_Click" />
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem x:Name="AppMenu_SeeWordBank" Click="AppMenu_SeeWordBank_Click" Text="See Wordbank" />
<shell:ApplicationBarMenuItem x:Name="AppMenu_SeeNotes" Click="AppMenu_SeeNotes_Click" Text="See Notes, " />
<!--following is line 38 -->
<shell:ApplicationBarMenuItem x:Name="AppMenu_SeeHighlights" Click="AppMenu_SeeHighlights_Click" Text="See Highlight" />
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
是的,我已经解决了这个问题,这是我的一个很小的错误,我真的为此感到难过,因为这是一个很小的错误 我确实在我的助手类中创建了App类的一个实例,所以正如您所知,App.xaml第一次执行得非常快,所以根据框架,无法创建App.xaml的两个实例 我已经修改了我的助手类 从 到
System.Windows.Application.LoadComponent(this, new System.Uri("/dbok;component/App.xaml", System.UriKind.Relative));
App myApp = new App();
//Following is the right way to access the properties from the App.xaml page.
App thisApp = (App)System.Windows.Application.Current;