XML error not understood

Trying to jump from decades of classic VB to .Net and WPF, I am working through this Microsoft tutorial: "Walkthrough: My First WPF Desktop Application", which is here: https://msdn.microsoft.com/en-gb/library/mt270964.aspx.

Nearing the end, I am getting this error, which doesn't appear to fit the actual code.
'The 'Grid' start tag on line 37 position 10 does not match the end tag of 'StackPanel'. Line 63, position 15.' XML is not valid.      

Note: the line numbers in the following code snippet are the same as those in the VS2015 IDE
<Page x:Class="ExpenseReportPage"
	  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
	  xmlns:local="clr-namespace:ExpenseIt"
	  mc:Ignorable="d" 
	  d:DesignHeight="300" d:DesignWidth="300"
	  Title="ExpenseIt – View Expense">
	<Grid Margin="10,0,10,10">
		<!--Templates to display expense report data-->
		<Grid.Resources>
			<!-- Reason item template -->
			<DataTemplate x:Key="typeItemTemplate">
				<Label Content="{Binding XPath=@ExpenseType}"/>
			</DataTemplate>
			<!-- Amount item template -->
			<DataTemplate x:Key="amountItemTemplate">
				<Label Content="{Binding XPath=@ExpenseAmount}"/>
			</DataTemplate>
		</Grid.Resources>

		<Grid.Background>
			<ImageBrush ImageSource="watermark.png" />
		</Grid.Background>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="230" />
			<ColumnDefinition />
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition />
		</Grid.RowDefinitions>
		<Label Grid.Column="1" Style="{StaticResource headerTextStyle}">
			Expense Report For:
		</Label>
		<Grid Margin="10" Grid.Column="1" Grid.Row="1">
			<Grid.ColumnDefinitions>
				<ColumnDefinition />
				<ColumnDefinition />
			</Grid.ColumnDefinitions>
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition />
			</Grid.RowDefinitions>

			<!-- Name -->
			<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Orientation="Horizontal">
				<Label Style="{StaticResource labelStyle}">Name:</Label>
				<Label Style="{StaticResource labelStyle}" Content="{Binding XPath=@Name}"></Label>
			</StackPanel>

			<!-- Department -->
			<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Orientation="Horizontal">
				<Label Style="{StaticResource labelStyle}">Department:</Label>
				<Label Style="{StaticResource labelStyle}" Content="{Binding XPath=@Department}"></Label>
			</StackPanel>

			<Grid Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2" VerticalAlignment="Top"   
			   HorizontalAlignment="Left">
				<!-- Expense type and Amount table -->
				<DataGrid ItemsSource="{Binding XPath=Expense}" ColumnHeaderStyle="{StaticResource columnHeaderStyle}" AutoGenerateColumns="False" RowHeaderWidth="0" >

					<DataGrid.Columns>
						<DataGridTextColumn Header="ExpenseType" Binding="{Binding XPath=@ExpenseType}"  />
						<DataGridTextColumn Header="Amount" Binding="{Binding XPath=@ExpenseAmount}" />
					</DataGrid.Columns>

				</DataGrid>
			</Grid>
		</Grid>
	</Grid>
</Page>

Open in new window

LVL 77
GrahamSkanRetiredAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

FaheemAhmadGulCommented:
I am not sure if it will help your problem or not, but the following XAML is not giving any error on my machine.
This XAML is almost exactly the same as yours except that I have taken out Style="{StaticResource labelStyle}"  from line 50 and 51, 56 and 57 I have also taken out ColumnHeaderStyle="{StaticResource columnHeaderStyle}"  from line 63 in your code and ImageSource="watermark.png"  from line 24 (primarily because I do not have these StaticResources on my machine)

<Page x:Class="ExpenseReportPage"
	  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
	  xmlns:local="clr-WpfApplication2"
	  mc:Ignorable="d" 
	  d:DesignHeight="300" d:DesignWidth="300"
	  Title="ExpenseIt – View Expense">
    <Grid Margin="10,0,10,10">
        <!--Templates to display expense report data-->
        <Grid.Resources>
            <!-- Reason item template -->
            <DataTemplate x:Key="typeItemTemplate">
                <Label Content="{Binding XPath=@ExpenseType}"/>
            </DataTemplate>
            <!-- Amount item template -->
            <DataTemplate x:Key="amountItemTemplate">
                <Label Content="{Binding XPath=@ExpenseAmount}"/>
            </DataTemplate>
        </Grid.Resources>

        <Grid.Background>
            <!-- ImageSource="watermark.png" -->
            <ImageBrush  />
        </Grid.Background>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="230" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Label Grid.Column="1" >
            Expense Report For:
        </Label>
        <Grid Margin="10" Grid.Column="1" Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>

            <!-- Name -->
            <StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Orientation="Horizontal">
                <Label  >Name:</Label>
                <Label  Content="{Binding XPath=@Name}"></Label>
            </StackPanel>

            <!-- Department -->
            <StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Orientation="Horizontal">
                <Label  >Department:</Label>
                <Label  Content="{Binding XPath=@Department}"></Label>
            </StackPanel>

            <Grid Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2" VerticalAlignment="Top"   
			   HorizontalAlignment="Left">
                <!-- Expense type and Amount table -->
                <DataGrid ItemsSource="{Binding XPath=Expense}"  AutoGenerateColumns="False" RowHeaderWidth="0" >

                    <DataGrid.Columns>
                        <DataGridTextColumn Header="ExpenseType" Binding="{Binding XPath=@ExpenseType}"  />
                        <DataGridTextColumn Header="Amount" Binding="{Binding XPath=@ExpenseAmount}" />
                    </DataGrid.Columns>

                </DataGrid>
            </Grid>
        </Grid>
    </Grid>
</Page>

Open in new window

0
GrahamSkanRetiredAuthor Commented:
Hi FaheemAhmadGul,
It's been a long time since you last posted a question that I could help with.

Thank you for your comment.
In accordance with the tutorial, that portion of the code has just been modified to link to an XmlDataProvider from another part of the project. It was that change that initiated the error.

I saved and closed the project after posting the question. After reopening, the design-time XML error has gone away, but I do get an XMLParseException when I try to run the project. I am still trying to find exactly where that is and whether it is the same problem problem in another guise

This is the error

System.Windows.Markup.XamlParseException was unhandled
Message: An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: 'Provide value on 'System.Windows.StaticResourceExtension' threw an exception.' Line number '29' and line position '55'.
0
FaheemAhmadGulCommented:
Yes Graham you did help me on so many occasions. In fact that the was start of my efforts to learn programming. I regard you as one of my teachers. I learned a lot from the help you gave me.
I am still learning, and by no means an expert yet , but I have gained some experience of WPF in the last few years.
I have completed a project following the Microsoft Tutorial that you mentioned and I did not get the error that you encountered in your project.
You can download the complete project from the following link:https://www.dropbox.com/sh/gfynprwmb7dzfnw/AADbaRveM_qBMHriU8zjPv5ha?dl=0

Please let me know if you are able to download the project and if it works on your machine.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GrahamSkanRetiredAuthor Commented:
Thank you. That is a great help. I will be able to see where I have gone wrong.
0
GrahamSkanRetiredAuthor Commented:
Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WPF

From novice to tech pro — start learning today.