xaml parse例外:属性{staticResource PhoneAccentBrush}値が範囲外です
-
14-11-2019 - |
質問
私は例外に問題があり、その修復方法についての答えを見つけることができませんでした。 属性{staticResource PhoneAccentBrush}値は範囲外です。
System.Windows.Application.LoadComponent(this, new System.Uri("/PAK_phone_side;component/Views/About/App_info.xaml", System.UriKind.Relative));
this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
this.TitlePanel = ((System.Windows.Controls.StackPanel)(this.FindName("TitlePanel")));
this.ApplicationTitle = ((System.Windows.Controls.TextBlock)(this.FindName("ApplicationTitle")));
this.PageTitle = ((System.Windows.Controls.TextBlock)(this.FindName("PageTitle")));
this.ContentPanel = ((System.Windows.Controls.Grid)(this.FindName("ContentPanel")));
this.textBlock1 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock1")));
.
Windows Phoneでボタンをクリックすると、app_info.g.i.csでは上記のコードがそのファイルからのSystem.Windows.Allication.LoadComponentで例外が発生します。上記のコードはそのファイルからです。
App_info.xaml のコンテンツパネル定義
<phone:PhoneApplicationPage
x:Class="windowsphoneapp.App_info"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="PAK " Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="App Infos" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock Height="311" HorizontalAlignment="Center" Margin="25,32,0,0" Name="textBlock1" Text="This Application is designed ...."
VerticalAlignment="Center" Width="425" Style="{StaticResource PhoneAccentBrush}" />
</Grid>
</Grid>
</phone:PhoneApplicationPage>
.
これはスタックトレースです
at System.Windows.Application.LoadComponent(オブジェクトコンポーネント、URI ResourceRocator) pak_phone_side.app_info.initializecomponent()で pak_phone_side.app_info..ctor()で System.Reflection.runtimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo RTCI、BindingFlags Invoyttr、Binder Binder、オブジェクトパラメータ、CultureInfo Culture、Boolean IsbinderDefault、アセンブリ呼び出し元、Boolean VerifyAccess&StackMark&StackMark&Stackmark) System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj、BindingFlags InvokeAttr、バインダーバインダー、オブジェクト[]パラメータ、CultureInfo Culture、StackCrawlmark&Stackmark) System.Activator.InternalCreateinstance(タイプタイプ、ブール非公開、StackCrawlmark&Stackmark) System.Activator.CreateInstanceで(タイプタイプ) System.Windows.Navigation.pageresourceContentLoader.beginload_onuithRead(AsyncCallback UserCallback、PageresOurcontentLoaderAsyncresult結果) System.Windows.Navigation.PageresOurContentLoader。<> c_ displayClass4.b _0(Object args) System.Reflection.RuntimeThodInfo.InternalInvoke(RuntimeMethodInfo RTMI、Object obj、BindingFlags InvokeAttr、バインダーバインダー、オブジェクトパラメータ、CultureInfo Culture、Boolean IsbinderDefault、アセンブリ呼び出し元、Boolean VerifyAccess&Stackmark&Stackmark&StackMark&StackMark) System.Reflection.RuntimeThodInfo.InternalInvoke(Object obj、BindingFlags Invokeattr、バインダーバインダー、オブジェクト[]パラメータ、CultureInfo Culture、StackCrawlmark&Stackmark) System.Reflection.MethodBase.Invoke(Object obj、Object []パラメータ) System.Delegate.DynamicInvokeOne(Object [] Args)で System.MulticastDelegate.dynamicInvokeImpl(Object [] Args) system.delegate.dynamicInvoke(Object [] args)で System.Windows.Threading.DispatcherOperation.Invoke() System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriality Priority) System.Windows.Threading.Dispatcher.OnInvoke(オブジェクトコンテキスト) System.Windows.Hosting.CallbackCookie.Invoke(Object [] args) system.windows.hosting.delegateWrapper.InternalInvoke(Object [] Args) System.Windows.Runtimehost.ManagedHost.Invokedelegate(intptr Phandle、INT32 NParamCount、ScriptParam [] Pparams、ScriptParam&Presulle)
解決
問題はこの行にあります:
<TextBlock Height="311" HorizontalAlignment="Center"
Margin="25,32,0,0" Name="textBlock1"
Text="This Application is designed ...."
VerticalAlignment="Center" Width="425"
Style="{StaticResource PhoneAccentBrush}" />
.
ブラシリソースの値をスタイルに設定しようとしています。これは例外を引き起こしているものです。XAMLを変更してみてください。
<TextBlock Height="311" HorizontalAlignment="Center"
Margin="25,32,0,0" Name="textBlock1"
Text="This Application is designed ...."
VerticalAlignment="Center" Width="425"
Style="{StaticResource PhoneTextNormalStyle}"
Foreground="{StaticResource PhoneAccentBrush}" />
.