title: Unclear problem with nullreferenceexception, C#, WPF
body: <p>There is a section of XAML code:</p>
  <pre><code>&lt;TextBox Name=&quot;CustomIdeologyNameTextBox1&quot; HorizontalAlignment=&quot;Left&quot; Height=&quot;32&quot; Margin=&quot;480,271,0,0&quot; TextWrapping=&quot;Wrap&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;125&quot; FontSize=&quot;15&quot; Text=&quot;Своя идеология1&quot; TextChanged=&quot;CustomIdeologyNameTextBox1_TextChanged&quot;/&gt;
  &lt;TextBox Name=&quot;CustomIdeologyNameTextBox2&quot; HorizontalAlignment=&quot;Left&quot; Height=&quot;32&quot; Margin=&quot;480,310,0,0&quot; TextWrapping=&quot;Wrap&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;125&quot; FontSize=&quot;15&quot; Text=&quot;Своя идеология2&quot; TextChanged=&quot;CustomIdeologyNameTextBox2_TextChanged&quot;/&gt;
  &lt;TextBox Name=&quot;CustomIdeologyNameTextBox3&quot; HorizontalAlignment=&quot;Left&quot; Height=&quot;32&quot; Margin=&quot;480,349,0,0&quot; TextWrapping=&quot;Wrap&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;125&quot; FontSize=&quot;15&quot; Text=&quot;Своя идеология3&quot; TextChanged=&quot;CustomIdeologyNameTextBox3_TextChanged&quot;/&gt;
  &lt;TextBox Name=&quot;CustomIdeologyNameTextBox4&quot; HorizontalAlignment=&quot;Left&quot; Height=&quot;32&quot; Margin=&quot;480,387,0,0&quot; TextWrapping=&quot;Wrap&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;125&quot; FontSize=&quot;15&quot; Text=&quot;Своя идеология4&quot; TextChanged=&quot;CustomIdeologyNameTextBox4_TextChanged&quot;/&gt;
  &lt;ComboBox HorizontalAlignment=&quot;Left&quot; Height=&quot;28&quot; Margin=&quot;480,432,0,0&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot;&gt;
              &lt;TextBlock&gt;democracy&lt;/TextBlock&gt;
              &lt;TextBlock&gt;communism&lt;/TextBlock&gt;
              &lt;TextBlockfascism&gt;&lt;/TextBlock&gt;
              &lt;TextBlock&gt;neutrality&lt;/TextBlock&gt;
              &lt;TextBlock Name=&quot;ComboBoxCustomIdeology1&quot; Text=&quot;Своя идеология 1&quot;&gt;&lt;/TextBlock&gt;
              &lt;TextBlock Name=&quot;ComboBoxCustomIdeology2&quot; Text=&quot;Своя идеология 2&quot;&gt;&lt;/TextBlock&gt;
              &lt;TextBlock Name=&quot;ComboBoxCustomIdeology3&quot; Text=&quot;Своя идеология 3&quot;&gt;&lt;/TextBlock&gt;
              &lt;TextBlock Name=&quot;ComboBoxCustomIdeology4&quot; Text=&quot;Своя идеология 4&quot;&gt;&lt;/TextBlock&gt;
          &lt;/ComboBox&gt;
  </code></pre>
  <p>And here is the code for it:</p>
  <pre><code>private void CustomIdeologyNameTextBox1_TextChanged(object sender, TextChangedEventArgs e)
          {
              try
              {
                  ComboBoxCustomIdeology1.Text = CustomIdeologyNameTextBox1.Text;
              }
              catch(NullReferenceException)
              {
                  ComboBoxCustomIdeology1.Text = &quot;-&quot;;
              }
          }
  
          private void CustomIdeologyNameTextBox2_TextChanged(object sender, TextChangedEventArgs e)
          {
              try
              {
                  ComboBoxCustomIdeology2.Text = CustomIdeologyNameTextBox2.Text;
              }
              catch
              {
                  ComboBoxCustomIdeology2.Text = &quot;-&quot;;
              }
  
          }
  
          private void CustomIdeologyNameTextBox3_TextChanged(object sender, TextChangedEventArgs e)
          {
              try
              {
                  ComboBoxCustomIdeology3.Text = CustomIdeologyNameTextBox3.Text;
              }
              catch
              {
                  ComboBoxCustomIdeology3.Text = &quot;-&quot;;
  
              }
          }
  
          private void CustomIdeologyNameTextBox4_TextChanged(object sender, TextChangedEventArgs e)
          {
              try { 
                  ComboBoxCustomIdeology4.Text = CustomIdeologyNameTextBox4.Text;
              }
              catch
              {
                  ComboBoxCustomIdeology3.Text = &quot;-&quot;;
              }
          }
  </code></pre>
  <p>That is, the last four options in the combobox must have the text of the four textboxes.
  But for some reason, when compiling, it throws a NullReferenceException. Processing blocks do not help - everything is the same. I will be grateful for your help.</p>