XamlParseException:无法找到名称/键PhoneBackgroundBrush的资源[行:47位置:111]

时间:2014-07-02 11:54:14

标签: xaml windows-phone-8 windows-phone visual-studio-express xamlparseexception

当我第一次开始开发时,一切都很好但是第二次启动项目时遇到了这个错误。由于xaml中存在错误,因此设计布局的预览从未显示过,所以我在这里盲目地工作。

做了一些研究,这个人和我一样有问题,但我尝试了他们的解决方案,但它对我不起作用,可能是因为他们正在使用Windows Phone 7.1而我正在使用8。这是链接:{{ 3}}

非常感谢任何帮助!

MainPage.xaml中:

<phone:PhoneApplicationPage
    x:Class="PetSounds.MainPage"
    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"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    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 Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
            <TextBlock Text="page name" 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">
            <Button Name="PlayAudioButton"
                    Height="200"
                    Width="200"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Top"
                    Background="Red"
                    Click="PlayAudioButton_Click_1">Quack</Button>
            <MediaElement x:Name="QuackMediaElement"
                          Source="/Assets/Audio/Animals/Duck.wav"
                          Volume="1"
                          AutoPlay="False"
                          />
        </Grid>
    </Grid>

</phone:PhoneApplicationPage> 

修改

这是App.Xaml文件:

<Application
    x:Class="PetSounds.App"
    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">

    <!--Application Resources-->
    <Application.Resources>
        <local:LocalizedStrings xmlns:local="clr-namespace:PetSounds" x:Key="LocalizedStrings"/>
    </Application.Resources>

    <Application.ApplicationLifetimeObjects>
        <!--Required object that handles lifetime events for the application-->
        <shell:PhoneApplicationService
            Launching="Application_Launching" Closing="Application_Closing"
            Activated="Application_Activated" Deactivated="Application_Deactivated"/>
    </Application.ApplicationLifetimeObjects>

</Application>

如果需要,请告诉我,我会发布其他文件。

0 个答案:

没有答案