title: Textbox.Text not updating in WPF
body: <p>Warning: I'm a complete WPF noob coming from a Windows forms background.</p>
  
  <p>I have a WPF UserControl, which in turn contains several other UserControls, each meant to display a certain chunk of data from a user's file. One of these controls simply shows name, address, and customer id.</p>
  
  <p>So, my main control looks like so:</p>
  
  <pre><code>&lt;UserControl x:Class="Plus.Gui.FileView"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
               mc:Ignorable="d" 
               d:DesignHeight="800" d:DesignWidth="1200" 
               xmlns:gui="clr-namespace:Plus.Gui"&gt;
      &lt;Grid&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="150*" /&gt;
              &lt;RowDefinition Height="150*" /&gt;
              &lt;RowDefinition Height="200*" /&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="488*" /&gt;
              &lt;ColumnDefinition Width="260*" /&gt;
              &lt;ColumnDefinition Width="252*" /&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;gui:pnlDebtor Grid.Column="2" HorizontalAlignment="Stretch" x:Name="pDebtor" VerticalAlignment="Stretch" /&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>The pnlDebtor control is the one that should show my info.</p>
  
  <p>The codebehind for my main control looks like so:</p>
  
  <pre><code>using System.Text;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Navigation;
  using System.Windows.Shapes;
  using MyDataLayer;
  
  namespace Plus.Gui
  {
      public partial class FileView : UserControl
      {
          public FileView()
          {
              InitializeComponent();
          }
  
          public FileView(MyCase file)
          {
              InitializeComponent();
              pDebtor = new pnlDebtor(file);
          }
      }
  }
  </code></pre>
  
  <p>I'm replacing my default pnlDebtor with a new one which loads the data from a file.</p>
  
  <p>Here's the xaml and a part of the codebehind for my pnlDebtor control.</p>
  
  <pre><code>&lt;UserControl x:Class="Plus.Gui.pnlDebtor"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
               mc:Ignorable="d" 
               d:DesignHeight="230" d:DesignWidth="460"&gt;
      &lt;Grid&gt;
          &lt;GroupBox Header="Debtor" HorizontalAlignment="Stretch" Margin="0,0,0,0" Name="groupBox1" VerticalAlignment="Stretch"&gt;
              &lt;Grid&gt;
                  &lt;Grid.RowDefinitions&gt;
                      &lt;RowDefinition Height="28" /&gt;
                      &lt;RowDefinition Height="56" /&gt;
                      &lt;RowDefinition Height="28" /&gt;
                      &lt;RowDefinition /&gt;
                  &lt;/Grid.RowDefinitions&gt;
                  &lt;Grid.ColumnDefinitions&gt;
                      &lt;ColumnDefinition Width="80*" /&gt;
                      &lt;ColumnDefinition Width="380*" /&gt;
                  &lt;/Grid.ColumnDefinitions&gt;
                  &lt;Label Content="Name:" Height="28" HorizontalAlignment="Left" Name="lblName" VerticalAlignment="Top" /&gt;
                  &lt;Label Content="Address:" Grid.Row="1" Height="28" HorizontalAlignment="Left" Name="lblAddress" VerticalAlignment="Top" /&gt;
                  &lt;Label Content="Customer Nr.:" Grid.Row="2" Height="28" HorizontalAlignment="Left" Name="lblCustomerNr" VerticalAlignment="Top" /&gt;
                  &lt;TextBox Grid.Column="1" Height="23" HorizontalAlignment="Stretch" Margin="0,0,0,0" Name="tbName" VerticalAlignment="Top" IsEnabled="False" IsReadOnly="False" /&gt;
                  &lt;TextBox Grid.Column="1" Grid.Row="1" Height="46" HorizontalAlignment="Stretch" Margin="0,0,0,0" Name="tbAddress" VerticalAlignment="Top" IsReadOnly="False" IsEnabled="True" /&gt;
                  &lt;TextBox Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Stretch" Margin="0,0,0,0" Name="tbCustomerNr" VerticalAlignment="Top" IsEnabled="True" IsReadOnly="False" /&gt;
                  &lt;Button Content="Debtor Details" Grid.ColumnSpan="2" Grid.Row="3" Height="23" HorizontalAlignment="Left" Margin="0,0,0,0" Name="btnDetails" VerticalAlignment="Top" /&gt;
              &lt;/Grid&gt;
          &lt;/GroupBox&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  
  public pnlDebtor(MyCase file)
  {
      InitializeComponent();
      Contact con = AbstractDataObject.GetObject4ID&lt;Contact&gt;(file.DebtorID);
      string strName = con.Name1;
  
      if (con.Name2 != null)
          strName += " " + con.Name2;
  
      if (con.Name3 != null)
          strName += " " + con.Name3;
  
      if (con.FirstName != null)
          strName += ", " + con.FirstName;
  
      tbName.Text = strName;
      tbAddress.Text = "test address";
      tbCustomerNr.Text = "test customer id";
  }
  </code></pre>
  
  <p>So, basically, I pass in the file and update the textboxes with the info from the file. Simple. Only, it doesn't work.</p>
  
  <p>If I set a breakpoint after the new pnlDebtor is created, and check the properties, tbName.Text, tbAddress.Text, and tbCustomerNr.Text have indeed been changed. But all the the boxes remain empty in the gui.</p>
  
  <p>If instead of assigning a new pnlDebtor, I simply change the values (pDebtor.tbName.Text = "Dummy") in the codebehind for the FileView control, it works fine.</p>
  
  <p>What am I missing here? Am I not able to replace an existing control with a new one this way?</p>
  
  <p>I've tried setting my original pnlDebtor to null before setting the new control, but got the same results. Somehow my control is being replaced but never being sent to the GUI.</p>