title: WPF TextBox not trimming in DataTemplate
body: <p>I have an odd problem with TextBox with TextTrimming set to CharacterElipsis used in a DataTemplate in WPF application. At the start of application everything works fine. But when I am resizing the window - reducing the width, the trimming is not working.</p>
  <p>In an example below:</p>
  <pre><code>&lt;Grid&gt;
          &lt;DockPanel&gt;
              &lt;DockPanel.Resources&gt;
                  &lt;DataTemplate x:Key=&quot;lowerLevel&quot; &gt;
                      &lt;Grid&gt;
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition Width=&quot;34*&quot; /&gt;
                              &lt;ColumnDefinition Width=&quot;26*&quot; /&gt;
                              &lt;ColumnDefinition Width=&quot;26*&quot; /&gt;
                              &lt;ColumnDefinition Width=&quot;14*&quot; /&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
                          &lt;TextBlock Text=&quot;textboxvalue1&quot; Grid.Column=&quot;0&quot; FontWeight=&quot;Bold&quot; VerticalAlignment=&quot;Center&quot; Margin=&quot;15,10,0,10&quot; TextTrimming=&quot;CharacterEllipsis&quot; TextWrapping=&quot;NoWrap&quot; /&gt;
                          &lt;TextBlock Text=&quot;textboxvalue2&quot; Grid.Column=&quot;1&quot; FontWeight=&quot;Bold&quot; VerticalAlignment=&quot;Center&quot; TextTrimming=&quot;CharacterEllipsis&quot; TextWrapping=&quot;NoWrap&quot;   /&gt;
                          &lt;TextBlock Text=&quot;textboxvalue3&quot; Grid.Column=&quot;2&quot; FontWeight=&quot;Bold&quot; VerticalAlignment=&quot;Center&quot;  Margin=&quot;0,10,0,10&quot; TextTrimming=&quot;CharacterEllipsis&quot; TextWrapping=&quot;NoWrap&quot;  /&gt;
                          &lt;CheckBox IsChecked=&quot;True&quot; Content=&quot;ApprovedText&quot;  FontWeight=&quot;Bold&quot; Grid.Column=&quot;3&quot;  VerticalAlignment=&quot;Center&quot;  Margin=&quot;0,10,15,10&quot; /&gt;
                      &lt;/Grid&gt;
                  &lt;/DataTemplate&gt;
              &lt;/DockPanel.Resources&gt;
              &lt;ListView x:Name=&quot;listViewControl&quot; ItemTemplate=&quot;{StaticResource lowerLevel}&quot; VerticalAlignment=&quot;Stretch&quot; VerticalContentAlignment=&quot;Stretch&quot;  HorizontalContentAlignment=&quot;Stretch&quot; /&gt;
              
          &lt;/DockPanel&gt;
          &lt;Grid&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width=&quot;34*&quot; /&gt;
                  &lt;ColumnDefinition Width=&quot;26*&quot; /&gt;
                  &lt;ColumnDefinition Width=&quot;26*&quot; /&gt;
                  &lt;ColumnDefinition Width=&quot;14*&quot; /&gt;
              &lt;/Grid.ColumnDefinitions&gt;
              &lt;TextBlock Text=&quot;textboxvalue1&quot; Grid.Column=&quot;0&quot; FontWeight=&quot;Bold&quot; VerticalAlignment=&quot;Center&quot; Margin=&quot;15,10,0,10&quot; TextTrimming=&quot;CharacterEllipsis&quot; TextWrapping=&quot;NoWrap&quot; /&gt;
              &lt;TextBlock Text=&quot;textboxvalue2&quot; Grid.Column=&quot;1&quot; FontWeight=&quot;Bold&quot; VerticalAlignment=&quot;Center&quot; TextTrimming=&quot;CharacterEllipsis&quot; TextWrapping=&quot;NoWrap&quot;   /&gt;
              &lt;TextBlock Text=&quot;textboxvalue3&quot; Grid.Column=&quot;2&quot; FontWeight=&quot;Bold&quot; VerticalAlignment=&quot;Center&quot;  Margin=&quot;0,10,0,10&quot; TextTrimming=&quot;CharacterEllipsis&quot; TextWrapping=&quot;NoWrap&quot;  /&gt;
              &lt;CheckBox IsChecked=&quot;True&quot; Content=&quot;ApprovedText&quot;  FontWeight=&quot;Bold&quot; Grid.Column=&quot;3&quot;  VerticalAlignment=&quot;Center&quot;  Margin=&quot;0,10,15,10&quot; /&gt;
          &lt;/Grid&gt;
      &lt;/Grid&gt;
  </code></pre>
  <p>I am having two identical Grids, but first one is placed in a DataTemplate and the second is just a separate control. TextBoxes in bottom grid are trimming correctly, when resizing window, however the TextBoxes from DataTemplate do not fit the width of parent columns while window resizing.</p>
  <p>The code behind is:</p>
  <pre><code>public partial class MainWindow : Window
      {
          private ListCollectionView comparedFamiliesView;
          public ListCollectionView ComparedFamiliesView
          {
              get
              {
                  if (comparedFamiliesView == null)
                  {
                      comparedFamiliesView = new ListCollectionView(new List&lt;Object&gt;() { new Object(), new Object(), new Object() });
                  }
                  return comparedFamiliesView;
              }
          }
          public MainWindow()
          {
              InitializeComponent();
              listViewControl.ItemsSource = ComparedFamiliesView;
          }
      }
  </code></pre>
  <p>It basically adds three objects to have something to view on ListView.</p>
  <p>I was trying different combinations of VerticalAlignment, VerticalContentAlignment - didn't work.
  What I have tried was to place each TextBox in separate Grid in order to bind its Width to TextBox Width or MaxWidth, like:</p>
  <pre><code>&lt;Grid Grid.Column=&quot;0&quot; x:Name=&quot;grid1&quot;&gt;
      &lt;TextBlock Text=&quot;textboxvalue1&quot; FontWeight=&quot;Bold&quot; VerticalAlignment=&quot;Center&quot; Margin=&quot;15,10,0,10&quot; TextTrimming=&quot;CharacterEllipsis&quot; TextWrapping=&quot;NoWrap&quot; MaxWidth=&quot;{Binding ActualWidth, ElementName=grid1}&quot; /&gt;
  &lt;/Grid&gt;
  </code></pre>
  <p>Didn't work either.</p>
  <p>How can I force TextBoxes in DataTemplate to behave the same way as those in separate Grid?
  Or what am I doing wrong with TextTrimming when using in DataTemplate.</p>
  <p>Thank you for your help!!!</p>
  <p>Regards,</p>
  <p>Ariel</p>