title: How to set default values in a WPF app?
body: <p>I'm new to WPF and fairly new to C# and I'm following along Head First C# 2nd Ed. p.218 (but a WPF version instead of a WinForms version). I have a <code>TextBox</code> on my form and I want to have a default string displayed when the form loads. I have two problems:</p>
  
  <ol>
  <li><p>If I set the <code>Text</code> property in my XAML code,  the <code>TextChanged</code> event fires on form load and I get a <code>NullReferenceException</code>. Here's my XAML snippet:</p>
  
  <p><code>&lt;TextBox Name="cakeWritingText" Text="Happy Birthday" TextChanged="cakeWritingText_TextChanged" /&gt;</code></p></li>
  <li><p>If I set the value in my code instead (and remove the XAML <code>Text</code> property) like this: <code>cakeWritingText.Text = "Happy Birthday";</code>, I get this error:</p></li>
  </ol>
  
  <blockquote>
    <p>No symbols are loaded for any call stack frame. The source code cannot be displayed.</p>
  </blockquote>
  
  <p>Here's the full event handler:</p>
  
  <pre><code>private void cakeWritingText_TextChanged(object sender, TextChangedEventArgs e)
  {
      birthdayParty.CakeWriting = cakeWritingText.Text;
      DisplayBirthdayPartyCost();
  }
  </code></pre>
  
  <p>and the <code>MainWindow</code> constructor:</p>
  
  <pre><code>public MainWindow()
  {
      InitializeComponent();
  
      dinnerParty = new DinnerParty(5, (bool)healthyCheckBox.IsChecked, (bool)fancyCheckBox.IsChecked);          
      DisplayDinnerCost();
  
      birthdayParty = new BirthdayParty(5, (bool)fancyBdayCheckBox.IsChecked, cakeWritingText.Text);
      numPeopleBdayUpDown.Value = 5;
      cakeWritingText.Text = "Happy Birthday";
      DisplayBirthdayPartyCost();
  }
  </code></pre>
  
  <p>What's the best way to put a default string in a <code>TextBox</code>?</p>