title: Setting TextTrimming (CharacterEllipsis) in DataGrid's Cell
body: <p>I would like to apply TextTrimming property (CharacterEllipsis) to the text in WPF DataGrid cells.</p>
  
  <p><img src="https://i.stack.imgur.com/Hc9vB.png" alt="DataGrid cells without TextTrimming set"></p>
  
  <p>I applied custom DataGridCell template as in <a href="https://stackoverflow.com/questions/3671608/wpf-datagrid-how-do-i-set-columns-to-textwrap">this answer</a> (code below) and it works well, except for the Hyperlink columns like the first one in the picture), which now are empty.</p>
  
  <p><img src="https://i.stack.imgur.com/eH0FL.png" alt="TextTrimming set on text columns, but hyperling column contents missing"></p>
  
  <pre><code>&lt;Style TargetType="DataGridCell"&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type DataGridCell}"&gt;
                  &lt;Border Padding="3" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True"&gt;
                      &lt;ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"&gt;
                          &lt;ContentPresenter.ContentTemplate&gt;
                              &lt;DataTemplate&gt;
                                  &lt;TextBlock TextTrimming="CharacterEllipsis" Text="{Binding Text}"/&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/ContentPresenter.ContentTemplate&gt;
                      &lt;/ContentPresenter&gt;
                  &lt;/Border&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>I can see the difference in both column types in visual tree:
  <img src="https://i.stack.imgur.com/2AqEe.png" alt="Datagrid row in visual tree (when no custom template is applied)"></p>
  
  <p>but don't understand how I can use this information to apply TextTrimming to TextBlock's columns of both type. Thanks for your time ;)</p>