title: StaticResource and DynamicResource in XAML
body: <p>I am currently browsing WPF examples on <a href="https://github.com/Microsoft/WPF-Samples/tree/master/Data%20Binding/SimpleBinding" rel="nofollow noreferrer">this</a> GitHub. This one is a simple application - it binds a textbox to a label. Whenever the textbox's text changes, the label is changed too via a data binding.</p>
  
  <p>Now, I'm reading a StaticResource is evaluated the moment the XAML object is constructed and cannot be changed later, while a DynamicResource is evaluated each time it is accessed.</p>
  
  <p>In this program, it would seem to me DynamicResources should be used, however only two StaticResources are present.</p>
  
  <p>Here is what I'd deem the crucial code:</p>
  
  <pre><code>// ...
  &lt;Window.Resources&gt;
      &lt;local:Person x:Key="MyDataSource" PersonName="Joe"/&gt;
      &lt;/Window.Resources&gt;
  // ...
              &lt;TextBox&gt;
              &lt;TextBox.Text&gt;
                  &lt;Binding Source="{StaticResource MyDataSource}" Path="PersonName"
                 UpdateSourceTrigger="PropertyChanged"/&gt;
              &lt;/TextBox.Text&gt;
          &lt;/TextBox&gt;
  
          &lt;Label&gt;The name you entered:&lt;/Label&gt;
          &lt;TextBlock Text="{Binding Source={StaticResource MyDataSource}, Path=PersonName}"/&gt;
  </code></pre>
  
  <p>How come it works with StaticResources?</p>