title: Why is my WPF window loading slowly?
body: <p>I am trying to design what is a pretty simple interface that shows a number of images and then rating buttons.  Here is the XAML.</p>
  
  <pre><code>   &lt;Window x:Class="ASU_Evaluation2.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:local ="clr-namespace:ASU_Evaluation2"
          Title="MainWindow" Height="686" Width="1154" Loaded="Window_Loaded" Closing="Window_Closing"&gt;
  
      &lt;Grid Name="ReviewData" &gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="200*"/&gt;
              &lt;ColumnDefinition Width="205"/&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="474*" /&gt;
              &lt;RowDefinition Height="25*" /&gt;
          &lt;/Grid.RowDefinitions&gt;
  
          &lt;StackPanel Grid.Column="1" Grid.RowSpan="2"&gt;
  
              &lt;ToggleButton Content="Cell is good" Name="tbGoodCell" Height="30" Margin="1,1" IsChecked="{Binding Cell_Good}"  Width="200"/&gt;
              &lt;ToggleButton Content="Recon is good" Name="tbReconGood" Height="30" Margin="1,1" IsChecked="{Binding Recon_Good}"  Width="200"/&gt;
              &lt;ToggleButton Content="Stain is good" Name="tbStainCell"  Height="30" Margin="1,1" IsChecked="{Binding GoodStain}"  Width="200"/&gt;
              &lt;ToggleButton Content="Recon Clipped" Name="tbReconClipped"  Height="30" Margin="1,1" IsChecked="{Binding Clipping}"  Width="200"/&gt;
              &lt;ToggleButton Content="Interesting" Name="tbInteresting"  Height="30" Margin="1,1" IsChecked="{Binding Interesting}"   Width="200"/&gt;
              &lt;ToggleButton Content="Background Noise" Name="tbNoisy"  Height="30" Margin="1,1" IsChecked="{Binding Noisy}"  Width="200"/&gt;
              &lt;ToggleButton Content="Has Rings" Name="tbRings"  Height="30" Margin="1,1" IsChecked="{Binding Rings}"  Width="200"/&gt;
              &lt;Label Content="Interfering Object" Margin="1,10,1,1"&gt;&lt;/Label&gt;
  
              &lt;ListBox Name="tbInterferingObject"  Height="70" SelectedIndex="{Binding InterferingObject}"  Width="200"&gt;
              &lt;ListBoxItem&gt;None          &lt;/ListBoxItem&gt;
                  &lt;ListBoxItem&gt;Close         &lt;/ListBoxItem&gt;
                  &lt;ListBoxItem&gt;Far           &lt;/ListBoxItem&gt;
                  &lt;ListBoxItem&gt;Side    &lt;/ListBoxItem&gt;
              &lt;/ListBox&gt;
  
              &lt;Label Content="Comments"/&gt;
              &lt;TextBox Margin="1,5" Height="400" Name="Comments" Text="{Binding Comments}" Width="200"/&gt;
  
          &lt;/StackPanel&gt;
  
          &lt;ComboBox Grid.Row="2" Grid.Column="0" x:Name="themes" Width="150" Height="20" SelectionChanged="themes_SelectionChanged" SelectedIndex="0" /&gt;
          &lt;TabControl Grid.Column="0"  Name="tabControl1" &gt;
              &lt;TabItem Header="Recon View" Name="tabItem1"&gt;
                  &lt;Grid Height="612" Width="934"&gt;
                      &lt;Grid.ColumnDefinitions&gt;
                          &lt;ColumnDefinition Width="225" /&gt;
                          &lt;ColumnDefinition Width="225" /&gt;
                          &lt;ColumnDefinition Width="225" /&gt;
                          &lt;ColumnDefinition Width="225*" /&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
                      &lt;Grid.RowDefinitions&gt;
                          &lt;RowDefinition Height="291" /&gt;
                          &lt;RowDefinition Height="291" /&gt;
                      &lt;/Grid.RowDefinitions&gt;
                      &lt;Image Grid.Column="0" Grid.Row="0"   Margin="2,2" Name="MIP_Image" Height="210" Width="210"/&gt;
                      &lt;Image Grid.Column="1" Grid.Row="0"   Margin="2,2" Name="Axial_Image" Source="{Binding Axial_Image}" Height="210" Width="210"/&gt;
                      &lt;Image Grid.Column="0" Grid.Row="1"   Margin="2,2" Name="Sag_Image" Source="{Binding Sag_Image}" Height="210" Width="210"/&gt;
                      &lt;Image Grid.Column="1" Grid.Row="1"   Margin="2,2" Name="Z_Image" Source="{Binding Z_Image}" Height="210" Width="210"/&gt;
                      &lt;Image Grid.Column="2" Grid.Row="0"   Margin="2,2" Name="Fly_Through"  Height="210" Width="210"/&gt;
                      &lt;Image Grid.Column="2" Grid.Row="1" Grid.ColumnSpan="2" Margin="2,2" Name="Background"  Source="{Binding Background}" Height="250" Width="450"/&gt;
                  &lt;/Grid&gt;
              &lt;/TabItem&gt;
              &lt;TabItem Header="Alignment View" Name="tabItem2"&gt;
                  &lt;Grid &gt;
                      &lt;Grid.ColumnDefinitions&gt;
                          &lt;ColumnDefinition Width="460" /&gt;
                          &lt;ColumnDefinition Width="460" /&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
                      &lt;Grid.RowDefinitions&gt;
                          &lt;RowDefinition Height="190" /&gt;
                          &lt;RowDefinition Height="190" /&gt;
                          &lt;RowDefinition Height="190" /&gt;
                      &lt;/Grid.RowDefinitions&gt;
                      &lt;Image Grid.Column="0" Grid.Row="0"   Margin="2,2" Name="PP1"   Source="{Binding PP1}" Width="460" Height="190" /&gt;
                      &lt;Image Grid.Column="0" Grid.Row="1"   Margin="2,2" Name="PP2"   Source="{Binding PP2}" Width="460" Height="190" /&gt;
                      &lt;Image Grid.Column="0" Grid.Row="2"   Margin="2,2" Name="PP3"   Source="{Binding PP3}" Width="460" Height="190" /&gt;
                      &lt;Image Grid.Column="1" Grid.Row="0" Grid.RowSpan="3"   Margin="2,2" Name="Centering" HorizontalAlignment="Center" VerticalAlignment="Center" Width="400" MinHeight="400"  Source="{Binding Centering}"/&gt;
  
                  &lt;/Grid&gt;
              &lt;/TabItem&gt;
              &lt;TabItem Header="Stack View" Name="tabItem3" GotFocus="tabItem3_GotFocus"&gt;
                  &lt;Grid &gt;
                      &lt;Grid.RowDefinitions&gt;
                          &lt;RowDefinition Height="418*" /&gt;
                          &lt;RowDefinition Height="24*" /&gt;
                      &lt;/Grid.RowDefinitions&gt;
                      &lt;Grid.ColumnDefinitions&gt;
                          &lt;ColumnDefinition Width="581*" /&gt;
                          &lt;ColumnDefinition Width="207*" /&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
                      &lt;Image Name="Stack_Image" VerticalAlignment="Center" HorizontalAlignment="Center" MinHeight="100" MinWidth="100"   Height="400" Margin="98,26,82,15" Width="400" /&gt;
                      &lt;ScrollBar Grid.Column="1" Height="353" HorizontalAlignment="Left" Margin="36,50,0,0" Name="StackZPosition" VerticalAlignment="Top" Width="17" ValueChanged="StackZPosition_ValueChanged" /&gt;
                      &lt;Label Content="Z Position" Grid.Column="1" Height="27" HorizontalAlignment="Left" Margin="13,17,0,0" Name="label1" VerticalAlignment="Top" Width="79" /&gt;
                      &lt;ProgressBar Grid.Row="1" Height="14" HorizontalAlignment="Left" Margin="95,4,0,0" Name="StackProgress" VerticalAlignment="Top" Width="404" /&gt;
                  &lt;/Grid&gt;
              &lt;/TabItem&gt;
              &lt;TabItem Header="Othogonal View" Name="tabItem4"&gt;
                  &lt;Grid &gt;
                      &lt;Grid.RowDefinitions&gt;
                          &lt;RowDefinition Height="418*" /&gt;
                          &lt;RowDefinition Height="24*" /&gt;
                      &lt;/Grid.RowDefinitions&gt;
                      &lt;Grid.ColumnDefinitions&gt;
                          &lt;ColumnDefinition Width="581*" /&gt;
                          &lt;ColumnDefinition Width="207*" /&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
  
                  &lt;/Grid&gt;
              &lt;/TabItem&gt;
          &lt;/TabControl&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>the class that is bound looks like this </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.IO;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Threading.Tasks;
  using System.Drawing;
  
  namespace ASU_Evaluation2
  {
  class DatasetExample
  {
        public string Date { get { return "3/3/3"; } }
      public ImageSource ExampleImage
      {
          get
          {
              string exampleImage = TopDirectory + @"\data\CrossSections_X___TIK.jpg";
  
              if (File.Exists(exampleImage))
                  return BitmapFrame.Create(new Uri(exampleImage, UriKind.Absolute), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
              else
                  return null;
          }
      }
      public bool Recon_Succeeded { get { return true; } }
      public bool Cell_Good
      {
          get;
          set;
      }
      public bool Recon_Good
      {
          get;
          set;
      }
      public string DatasetName { get; private set; }
      public string TopDirectory { get; private set; }
  
  
      string VGFolder;
      string StorageFolder;
      string DehydrateFolder;
      string BackupFolder;
      string StackFolder;
      string StackReportFilePath;
  
      private void BuildPaths()
      {
          string dirName = Path.GetFileNameWithoutExtension(TopDirectory);
          //return dirName;
          string[] parts = dirName.Split('_');
          string Prefix = parts[0];
          string Year = parts[1].Substring(0, 4);
          string month = parts[1].Substring(4, 2);
          string day = parts[1].Substring(6, 2);
  
          VGFolder = Path.Combine(@"y:\", Prefix + "\\" + Year + month + "\\" + day + "\\" + dirName);
          StorageFolder = Path.Combine(@"z:\", Prefix + "\\" + Year + month + "\\" + day + "\\" + dirName);
          DehydrateFolder = Path.Combine(@"e:\", Prefix + "\\" + Year + month + "\\" + day + "\\" + dirName);
          BackupFolder = Path.Combine(@"V:\BackupCompleted\", Prefix + "\\" + Year + month + "\\" + day + "\\" + dirName);
  
          if (Prefix.ToLower() == "cct001")
          {
              StackFolder = Path.Combine(@"V:\Raw PP\cct001\Absorption\", Year + month + "\\" + day + "\\" + dirName + "\\STACK\\000");
          }
          else
              StackFolder = Path.Combine(@"V:\Raw PP\", Prefix + "\\" + Year + month + "\\" + day + "\\" + dirName + "\\STACK\\000");
  
          StackReportFilePath = VGFolder + "\\FixedStackReport.xml";
      }
  
      public DatasetExample(string name, string path)
      {
          DatasetName = name;
          TopDirectory = path;
          GoodStain = true;
          Clipping = false;
          Interesting = false;
          Noisy = false;
          Rings = false;
          InterferingObject = 0;
          Comments = "  ";
          Evaluator = "Brian";
          Cell_Good = true;
          CellType = " ";
          Recon_Good = true;
  
      }
  
      public string Evaluator { get; set; }
      public string CellType { get; set; }
      public bool GoodStain { get; set; }
      public bool Clipping { get; set; }
      public bool Interesting { get; set; }
      public bool Noisy { get; set; }
      public bool Rings { get; set; }
      public int  InterferingObject { get; set; }
      public string Comments { get; set; }
  
  
  
      public ImageSource Axial_Image
      {
          get
          {
              string exampleImage = TopDirectory + @"\data\CrossSections_X___TIK.jpg";
  
              if (File.Exists(exampleImage))
                  return BitmapFrame.Create(new Uri(exampleImage, UriKind.Absolute), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
              else
                  return null;
          }
      }
      public ImageSource Sag_Image
      {
          get
          {
              string exampleImage = TopDirectory + @"\data\CrossSections_Y___TIK.jpg";
  
              if (File.Exists(exampleImage))
                  return BitmapFrame.Create(new Uri(exampleImage, UriKind.Absolute), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
              else
                  return null;
          }
      }
      public ImageSource Z_Image
      {
          get
          {
              string exampleImage = TopDirectory + @"\data\CrossSections_Z___TIK.jpg";
  
              if (File.Exists(exampleImage))
                  return BitmapFrame.Create(new Uri(exampleImage, UriKind.Absolute), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
              else
                  return null;
          }
      }
  
  
      public void ClearMemory()
      {
  
  
  
      }
  
      public ImageSource Background
      {
          get
          {
              string exampleImage = TopDirectory + @"\data\background.tif";
  
              if (File.Exists(exampleImage))
                  return BitmapFrame.Create(new Uri(exampleImage, UriKind.Absolute), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
              else
                  return null;
          }
      }
      public ImageSource PP1
      {
          get
          {
              string exampleImage = TopDirectory + @"\data\projection1.jpg";
  
              if (File.Exists(exampleImage))
                  return BitmapFrame.Create(new Uri(exampleImage, UriKind.Absolute), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
              else
                  return null;
          }
      }
      public ImageSource PP2
      {
          get
          {
              string exampleImage = TopDirectory + @"\data\projection2.jpg";
  
              if (File.Exists(exampleImage))
                  return BitmapFrame.Create(new Uri(exampleImage, UriKind.Absolute), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
              else
                  return null;
          }
      }
      public ImageSource PP3
      {
          get
          {
              string exampleImage = TopDirectory + @"\data\projection3.jpg";
  
              if (File.Exists(exampleImage))
                  return BitmapFrame.Create(new Uri(exampleImage, UriKind.Absolute), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
              else
                  return null;
          }
      }
      public string Centering
      {
          get
          {
              string exampleImage = TopDirectory + @"\data\centering.avi";
  
              if (File.Exists(exampleImage))
                  return exampleImage;
              else
                  return "";
          }
      }
  
      public ImageSource Stack_Image
      {
          get
          {
              string exampleImage = TopDirectory + @"\data\CrossSections_Y___TIK.jpg";
  
              if (File.Exists(exampleImage))
                  return BitmapFrame.Create(new Uri(exampleImage, UriKind.Absolute), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
              else
                  return null;
          }
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>It takes 15-20 seconds to load the interface on a high end computer.  I have tried to run the performance monitor tool with the windows SDK and it just crashes.  What am I doing wrong?  This is a embarrassingly simple task in winforms.</p>