XAML-Parse-Ausnahme:Der Wert des Attributs {StaticResource PhoneAccentBrush} liegt außerhalb des gültigen Bereichs

StackOverflow https://stackoverflow.com/questions/5006100

Frage

Ich habe ein Problem mit einer Ausnahme und konnte keine Antwort darauf finden, wie ich das Problem beheben kann.Der Wert des Attributs {StaticResource PhoneAccentBrush} liegt außerhalb des gültigen Bereichs.

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")));

Wenn ich in Windows Phone auf die Schaltfläche App_info_Button klicke, tritt die Ausnahme bei System.Windows.Apllication.LoadComponent auf. In App_info.g.i.cs stammt der obige Code aus dieser Datei.

Hier ist die Content-Panel-Definition in 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>

Dies ist der Stack-Trace

at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator) at PAK_phone_side.App_info.InitializeComponent() at PAK_phone_side.App_info..ctor() at System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark) at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark) at System. Activator.InternalCreateinstance (Typtyp, boolean nicht öffentlich, Stackcrawlmark & ​​Stackmark) bei System.Activator.CreateInstance (Typtyp) bei System.Windows cecontentloader. < > c_DisplayClass4.b_0 (Objekt args) at system.reflection.runtimemethodinfo.internalinvoke (Runtimemethodinfo Rtmi, Objekt Obj, BindingFlags Invokeattrtr, Binder Binder, Objektparameter, CultureInfo -Kultur, booläische ISBinderdefault, Assemble, BOOLANDECESSPRIKET, BOOLANELAN -Verifizierung, Boolan -Verifizierung, Boolan -Verifizierung, Staplmarke & Stackmark & ​​Stackmark), BOOLEANDECESSCESCESS, BOOLANELAN -VERFICESPELN, BOOLANELANDECESSGELN, BOOLANELANDECESS, BOOLANELANDECESS, BOOLANELANDECESS. o .InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at System.Delegate.DynamicInvokeOne(Object[] args) at System.MulticastDelegate.DynamicInvokeImpl(Object[] args) at System.Delegate.DynamicInvoke(Object[] args) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority Priorität) at system.windows.threading.dispatcher.oninvoke (Objektkontext) at system.windows.hosting.callbackcookie.invoke (Objekt [] args) at system.windows.hosting.delegateWrapper.internalinvoke (Object [] args) at system at system at system at system at system at system auf .Windows.RuntimeHost.Managedhost.Invokedelegate (intptr phandle, int32 nparamcount, scriptparam [] pparams, scriptparam & presult)

War es hilfreich?

Lösung

Das Problem liegt in dieser Zeile:

<TextBlock Height="311" HorizontalAlignment="Center" 
           Margin="25,32,0,0" Name="textBlock1" 
           Text="This Application is designed ...." 
           VerticalAlignment="Center" Width="425" 
           Style="{StaticResource PhoneAccentBrush}" />

Sie versuchen, einen Pinselressourcenwert auf einen Stil festzulegen, was die Ausnahme verursacht.Sie könnten versuchen, das XAML wie folgt zu ändern:

<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}" />
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top