XAML analyser Exception:Attribut {StaticResource PhoneAccentBrush} valeur est en dehors de la plage

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

Question

J'ai un problème avec une Exception, ne pouvait pas trouver la réponse sur la façon de le résoudre.Attribut {StaticResource PhoneAccentBrush} valeur est hors de portée.

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

Dans windows phone quand je clique sur le bouton App_info_Button l'exception se produit sur le Système.De Windows.Apllication.LoadComponent Dans App_info.g.j'.cs , le code ci-dessus est à partir de ce fichier.

voici le contenu définition du groupe d'experts sur 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>

C'est la trace de la Pile

au Système.De Windows.Application.LoadComponent(composant Objet, Uri resourceLocator) au PAK_phone_side.App_info.InitializeComponent() au PAK_phone_side.App_info..ctor() au Système.De la réflexion.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder Binder, les paramètres de l'Objet, CultureInfo culture, Boolean isBinderDefault, de l'Assemblée de l'appelant, Boolean verifyAccess, StackCrawlMark& stackMark) au Système.De la réflexion.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder Binder, Object[] paramètres, CultureInfo culture, StackCrawlMark& stackMark) au Système.Activateur.InternalCreateInstance(Type de type Boolean non publiques, StackCrawlMark& stackMark) au Système.Activateur.CreateInstance(Type) au Système.De Windows.La Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(AsyncCallback userCallback, PageResourceContentLoaderAsyncResult suite) au Système.De Windows.La Navigation.PageResourceContentLoader.<>c_DisplayClass4.b_0(Objet args) au Système.De la réflexion.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder Binder, les paramètres de l'Objet, CultureInfo culture, Boolean isBinderDefault, de l'Assemblée de l'appelant, Boolean verifyAccess, StackCrawlMark& stackMark) au Système.De la réflexion.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder Binder, Object[] paramètres, CultureInfo culture, StackCrawlMark& stackMark) au Système.De la réflexion.MethodBase.Invoke(Object obj, Object[] paramètres) au Système.Délégué.DynamicInvokeOne(Object[] args) au Système.MulticastDelegate.DynamicInvokeImpl(Object[] args) au Système.Délégué.DynamicInvoke(Object[] args) au Système.De Windows.Le filetage.DispatcherOperation.Invoke() au Système.De Windows.Le filetage.Répartiteur.Dispatch(DispatcherPriority priorité) au Système.De Windows.Le filetage.Répartiteur.OnInvoke(contexte de l'Objet) au Système.De Windows.De l'hébergement.CallbackCookie.Invoke(Object[] args) au Système.De Windows.De l'hébergement.DelegateWrapper.InternalInvoke(Object[] args) au Système.De Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)

Était-ce utile?

La solution

Le problème, c'est cette ligne:

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

Vous essayez de définir une brosse à la valeur de la ressource à un style, qui est ce qui est à l'origine de l'exception.Vous pouvez essayer de changer le code 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}" />
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top