title: Data at the root level is invalid. Line 1, position 1. XML is not valid
body: <p>I have two errors in my code: </p>
  
  <ul>
  <li>Data at the root level is invalid. Line 1, position 1.</li>
  <li>Markup file is not valid. Specify a source markup file with an .xaml extension.   </li>
  </ul>
  
  <p>Why?</p>
  
  <p>MainWindow.xaml:</p>
  
  <pre><code>&lt;Window x:Class="TestWpfApplication.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Eight Ball Answer" Height="328" Width="412" &gt;
      &lt;Grid Name="grid1"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="*" /&gt;
              &lt;RowDefinition Height="Auto" /&gt;
              &lt;RowDefinition Height="*" /&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;TextBox VerticalAlignment="Stretch" HorizontalAlignment="Stretch"     Margin="10,10,13,10" Name="txtQuestion"      TextWrapping="Wrap" FontFamily="Verdana" FontSize="24"     Grid.Row="0"&gt;[Place question here.]&lt;/TextBox&gt;
          &lt;Button VerticalAlignment="Top" HorizontalAlignment="Left"     Margin="10,0,0,20" Width="127" Height="23" Name="cmdAnswer"     Click="cmdAnswer_Click" Grid.Row="1"&gt;Ask the Eight Ball&lt;/Button&gt;
          &lt;TextBox VerticalAlignment="Stretch" HorizontalAlignment="Stretch"     Margin="10,10,13,10" Name="txtAnswer" TextWrapping="Wrap"     IsReadOnly="True" FontFamily="Verdana" FontSize="24" Foreground="Green"     Grid.Row="2"&gt;[Answer will appear here.]&lt;/TextBox&gt;
          &lt;Grid.Background&gt;
              &lt;LinearGradientBrush&gt;
                  &lt;LinearGradientBrush.GradientStops&gt;
                      &lt;GradientStop Offset="0.00" Color="Red" /&gt;
                      &lt;GradientStop Offset="0.50" Color="Indigo" /&gt;
                      &lt;GradientStop Offset="1.00" Color="Violet" /&gt;
                  &lt;/LinearGradientBrush.GradientStops&gt;
              &lt;/LinearGradientBrush&gt;
          &lt;/Grid.Background&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>MainWindow.xaml.cs:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Navigation;
  using System.Windows.Shapes;
  
  namespace TestWpfApplication
  {
      /// &lt;summary&gt;
      /// Interaction logic for MainWindow.xaml
      /// &lt;/summary&gt;
      public partial class MainWindow : Window
      {
          public MainWindow()
          {
              InitializeComponent();
          }
  
          private void cmdAnswer_Click(object sender, RoutedEventArgs e)
          {
              this.Cursor = Cursors.Wait;            
  
              txtAnswer.Text = "AAA";
              this.Cursor = null;
          }
      }
  }
  </code></pre>
  
  <p>Update 1:</p>
  
  <ol>
  <li>This page was created by copy&amp;paste method, not by designer.</li>
  <li>MainWindow.xaml has property BuildAction set to Page.</li>
  </ol>
  
  <p>Is if helpful?</p>