我有一個異常的問題,無法找到如何解決它的答案。 屬性{StaticResource PhoneAccentBrush}值超出範圍。XAML解析異常:屬性{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_Button例外發生在System.Windows.Apllication.LoadComponent在App_info.g.i.cs,上面的代碼是從該文件。
這裏是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>
內容面板定義這是堆棧跟蹤
在System.Windows.Application.LoadComponent(對象組件,烏里resourceLocator) 在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,Ass embly呼叫者,布爾verifyAccess,StackCrawlMark & stackMark) 在System.Reflection.RuntimeConstructorInfo.InternalInvoke(對象OBJ,的BindingFlags invokeAttr,粘結劑粘結劑,對象在System.Activator.InternalCreateInstance []參數,CultureInfo的文化,StackCrawlMark & stackMark) (類型型,非公開布爾,StackCrawlMark & stackMark) 在System.Activator.CreateInstance(類型類型) 在System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(的AsyncCallback userCallback,PageResourceContentLoaderAsyncResult結果) 在System.Windows.Navigation.PageResourceContentLoader。 <> C_ DisplayClass4.b _0(對象參數) 在System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi,對象OBJ,的BindingFlags invokeAttr,粘結劑粘結劑,對象參數,CultureInfo的文化,布爾isBinderDefault,裝配呼叫者,布爾verifyAccess, StackCrawlMark & stackMark) 在System.Reflection.RuntimeMethodInfo.InternalInvoke(對象OBJ,的BindingFlags invokeAttr,粘結劑粘結劑,對象[]參數,CultureInfo的文化,StackCrawlMark & stackMark) 在System.Reflection.MethodBase.Invoke(對象OBJ,對象[ ]參數) 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 priority) at System.Windows.Threading.Dispatcher.OnInvoke在System.Windows.Hosting.DelegateWrapper.InternalInvoke(對象[]參數)在System.Windows.Hosting.CallbackCookie.Invoke(對象[]參數) (對象上下文) 在System.Windows.RuntimeHost.ManagedHost.InvokeDelegate( IntPtr的pHandle,的Int32 nParamCount,ScriptParam [] pParams,ScriptParam & pResult)
'PhoneAccentBrush`是一個有效的系統資源,因此應該可以在任何地方解析。你能發佈包含所謂無效屬性的XAML代碼嗎? (可能它的視覺樹比目前爲止顯示的要高) – 2011-02-15 16:22:37
XAML並沒有包含很多簡單的 – 2011-02-15 17:00:33