A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in


  • Hi Guys,

    I am developing my first WP8 app. I am getting the following error:

    A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in

    What is the solution to rectify this exception.


    Tuesday, December 17, 2013 7:10 PM


  • Hi, mSpot Inc.

    Yes, you have exception in your code, because you need set


    But no

    Grid.Row=" 0"

    Regards, Nikita

    • Edited by Mykyta Bondarenko Saturday, December 21, 2013 11:16 AM
    • Marked as answer by Sujit Rai Saturday, December 21, 2013 6:41 PM
    Saturday, December 21, 2013 11:15 AM

All replies

  • Does the exception crash your app if you don't handle it?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, December 17, 2013 8:39 PM
  • I am running the app in visual studio. Just to learn i started this App (Calculator). Following is my MainPage.xaml and screenshot.

        FontFamily="{StaticResource PhoneFontFamilyNormal}"
        FontSize="{StaticResource PhoneFontSizeNormal}"
        Foreground="{StaticResource PhoneForegroundBrush}"
        SupportedOrientations="Portrait" Orientation="Portrait"
        <!--LayoutRoot is the root grid where all page content is placed-->
        <Grid x:Name="LayoutRoot" Background="Transparent">
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            <!-- LOCALIZATION NOTE:
                To localize the displayed strings copy their values to appropriately named
                keys in the app's neutral language resource file (AppResources.resx) then
                replace the hard-coded text value between the attributes' quotation marks
                with the binding clause whose path points to that string name.
                For example:
                    Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"
                This binding points to the template's string resource named "ApplicationTitle".
                Adding supported languages in the Project Properties tab will create a
                new resx file per language that can carry the translated values of your
                UI strings. The binding in these examples will cause the value of the
                attributes to be drawn from the .resx file that matches the
                CurrentUICulture of the app at run time.
            <!--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 Calculator" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
                <TextBlock Text="CALCULATOR" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
            <!--ContentPanel - place additional content here-->
            <Grid x:Name="ContentPanel" Grid.Row="2" Margin="12,0,12,0">
                    <RowDefinition Height="80"/>
                <TextBox Name="txtArea" FontSize="16" FontWeight="Bold" FlowDirection="RightToLeft" InputScope="Number" IsReadOnly="True" />
                <Grid x:Name="ContentPanel1" Grid.Row="2" Margin="12,0,12,0">
                    <Button Name="btnSqrt" BorderBrush="DarkBlue" Content="Sqrt."/>
                    <Button Name="btnSquare" BorderBrush="DarkBlue" Content="x2" Grid.Row="0" Grid.Column="1"/>
                    <Button Name="btnModulo" BorderBrush="DarkBlue" Content="%" Grid.Row=" 0" Grid.Column="2"/>
                    <Button Name="btnPlus" BorderBrush="DarkBlue" Content="+" Grid.Column="3"/>
                    <Button Name="btnSeven" BorderBrush="DarkBlue" Content="7" Grid.Row=" 1"/>
                    <Button Name="btnEight" BorderBrush="DarkBlue" Content=" 8" Grid.Row=" 1" Grid.Column=" 1"/>
                    <Button Name="btnNine" BorderBrush="DarkBlue" Content="9" Grid.Row="1" Grid.Column=" 2"/>
                    <Button Name="btnMinus" BorderBrush="DarkBlue" Content="-" Grid.Row=" 1" Grid.Column=" 3"/>
                    <Button Name="btnFour" BorderBrush="DarkBlue" Content=" 4" Grid.Row=" 2"/>
                    <Button Name="btnFive" BorderBrush="DarkBlue" Content="5" Grid.Row=" 2" Grid.Column="1 "/>
                    <Button Name="btnSix" BorderBrush="DarkBlue" Content=" 6" Grid.Column=" 2" Grid.Row=" 2"/>
                    <Button Name="btnMuliply" BorderBrush="DarkBlue" Content="*" Grid.Column=" 3" Grid.Row=" 2"/>
                    <Button Name="btnOne" BorderBrush="DarkBlue" Content="1" Grid.Row=" 3"/>
                    <Button Name="btnTwo" BorderBrush="DarkBlue" Content=" 2" Grid.Row=" 3" Grid.Column="1"/>
                    <Button Name="btnThree" BorderBrush="DarkBlue" Content=" 3" Grid.Row=" 3" Grid.Column ="2"/>
                    <Button Name="btnDevide" BorderBrush="DarkBlue" Content="/" Grid.Row="3" Grid.Column="3"/>
                    <Button Name="btnDblZero" BorderBrush="DarkBlue" Content=" 00" Grid.Row=" 4"/>
                    <Button Name="btnZero" BorderBrush="DarkBlue" Content="0" Grid.Column=" 1" Grid.Row="4"/>
                    <Button Name ="btnDot" BorderBrush="DarkBlue" Content="." Grid.Column=" 2" Grid.Row=" 4"/>
                    <Button Name="btnEqual" BorderBrush="DarkBlue" Content="=" Grid.Row=" 4" Grid.Column=" 3"/>
            <!--Uncomment to see an alignment grid to help ensure your controls are
                aligned on common boundaries.  The image has a top margin of -32px to
                account for the System Tray. Set this to 0 (or remove the margin altogether)
                if the System Tray is hidden.
                Before shipping remove this XAML and the image itself.-->
            <!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />-->

    Saturday, December 21, 2013 8:30 AM
  • Hi, Sujit Rai.

    Give us message of exception please.

    And I see small mistakes in you xaml:

     - You wrong set Grid.Row property when set it in Grid.Row=2, because numbering starts with 0 (you need Grid.Row=1)

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

    - Recheck Grid.Row property and Grid.Column property in other cases (Buttons etc.)

    And XamlParseException often occurred when app can't find any resources.

    Regards, Nikita.

    Saturday, December 21, 2013 9:02 AM
  • I copy and pasted your xaml into a page, and saw the error happen. If you look at the error details, it says:

        System.Windows.Markup.XamlParseException occurred
          Message=Failed to create a 'System.Int32' from the text ' 0'. [Line: 71 Position: 86]

    This is line 71 of your xaml (in the code editor, the bottom right shows the line/column of the cursor):
        <Button Name="btnModulo" BorderBrush="DarkBlue" Content="%" Grid.Row=" 0" Grid.Column="2"/>

    The error is subtle and unexpected. You wrote Grid.Row=" 0" (with a space in front of the 0). You need to remove the space: Grid.Row="0". It is odd that the designer preview accepts the space but the runtime does not. You need to go through all of your Grid.Column and Grid.Row values and make sure that none of them have embedded spaces.

    Richard Woo
    Saturday, December 21, 2013 10:06 AM
  • Hi, mSpot Inc.

    Yes, you have exception in your code, because you need set


    But no

    Grid.Row=" 0"

    Regards, Nikita

    • Edited by Mykyta Bondarenko Saturday, December 21, 2013 11:16 AM
    • Marked as answer by Sujit Rai Saturday, December 21, 2013 6:41 PM
    Saturday, December 21, 2013 11:15 AM
  • Thanks Nikita it worked. It was a blank space issue.

    • Edited by Sujit Rai Saturday, December 21, 2013 6:43 PM
    Saturday, December 21, 2013 6:42 PM
  • You Should Set Your element As You Should put your elements inside the Grid and if You have more than Grid You should set element inside grid for example you can put grid inside grid and So on
    Thursday, February 20, 2014 8:58 AM