Search code examples
c#xamlexceptionwindows-phone-8appbar

XAML parsing exception compiling Windows Phone 8 project


I'm trying to compile a Windows Phone 8 project on Visual Studio IDE 2013 and I get an error with the parsing of the MainPage.xaml.

In the following code I get the error Windows.UI.Xaml.Markup.XamlParseException. What I wrong? The issue is originated in the line of the opening AppBar tag.

<Page
    x:Class="MainStream.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MainStream"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
        <Image Grid.RowSpan="2" Stretch="None" Source="/img/sfondo.png" VerticalAlignment="Top" HorizontalAlignment="Center"/>
        <FlipView x:Name="flipView1" Width="480" Height="270" Margin="0,10,0,0" VerticalAlignment="Top" BorderBrush="Black" BorderThickness="1">
            <Image Width="480" Height="270" Stretch="UniformToFill"/>
            <TextBlock FontFamily="Segoe UI" FontSize="26.667" Foreground="#CCFFFFFF" Padding="15,20"/>
        </FlipView>

        <AppBar VerticalAlignment="Bottom" HorizontalAlignment="Center">
            <StackPanel Orientation="Horizontal">
                <AppBarButton Click="Play_Click" Label="Play" Icon="Play"/>
                <AppBarButton Click="Pause_Click" Label="Pause" Icon="Pause"/>
            </StackPanel>
        </AppBar>
    </Grid>
</Page>

The error is:

Cannot create instance of type '%0' [Line: 18 Position: 17] The text associated with this error code could not be found.

Anyone can suggest me a solution?


Solution

  • I don't believe that the appbar should be a child of the grid element and I am not sure that you are using the correct format for a appbar. The correct way would be something similar to below:

    <Page
        x:Class="MainStream.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:MainStream"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    
        <Grid>
            <Image Grid.RowSpan="2" Stretch="None" Source="/img/sfondo.png" VerticalAlignment="Top" HorizontalAlignment="Center"/>
            <FlipView x:Name="flipView1" Width="480" Height="270" Margin="0,10,0,0" VerticalAlignment="Top" BorderBrush="Black" BorderThickness="1">
                <Image Width="480" Height="270" Stretch="UniformToFill"/>
                <TextBlock FontFamily="Segoe UI" FontSize="26.667" Foreground="#CCFFFFFF" Padding="15,20"/>
            </FlipView>
       </Grid>
    
        <Page.BottomAppBar>
            <CommandBar Opacity="1">
                <AppBarButton x:Name="AddAppBarButton" Label="add" Icon="Add"  />
                <CommandBar.SecondaryCommands>
                    <AppBarButton x:Uid="SecondaryButton1" x:Name="SecondaryButton1" Label="secondary command 1" />
                    <AppBarButton x:Uid="SecondaryButton2" x:Name="SecondaryButton2" Label="secondary command 2" />
                </CommandBar.SecondaryCommands>
            </CommandBar>
        </Page.BottomAppBar>
    
    </Page>