title: How are objects instantiated by XAML?
body: <p>I'm developing a WPF application using the MVVM pattern and Entity Framework.  I wrote a class that contains a bunch of lists that get populated from the database.  The lists are used to populate <code>ComboBoxes</code> and other `ItemsControls.</p>
  
  <p>Here's the basic structure:</p>
  
  <pre><code>namespace MiniManager.ViewModel
  {
      public class LookupLists
      {
          public LookupLists()
          {
              using (var db = new ModelContext())
              {
                  Supervisors = db.Users.ToList().Where(u =&gt; u.Supervisor);
                  // More lists...
              }
          }
  
          public IEnumerable&lt;User&gt; Supervisors { get; set; }
          // More lists...
      }
  }
  </code></pre>
  
  <p>I use the class in the view like this:</p>
  
  <pre><code>&lt;UserControl.Resources&gt;
      &lt;lists:LookupLists x:Key="LookupLists"/&gt;
  &lt;/UserControl.Resources&gt;
  </code></pre>
  
  <p>When I need to use it on a control I bind to a property in the resource:</p>
  
  <pre><code>&lt;ComboBox ItemsSource="{Binding Source={StaticResource LookupLists},
                          Path=Supervisors}"/&gt;
  </code></pre>
  
  <p>My question is this:</p>
  
  <ul>
  <li>How long does the <code>LookupLists</code> object last?<br>
  <ul>
  <li>As long as the UI is active?  </li>
  <li>Is a new instance of <code>LookupLists</code> created (and therefore the database queried) every time the view needs it?</li>
  </ul></li>
  </ul>