title: Passing a cell's contents into a converter in XAML
body: <p>I'm trying to create a style that aligns a cell based on the type of its contents. If it's text, it's aligned to the left, if it's a number, it's aligned to the right. I've tried to create a converter that returns an alignment based on the value given to it. Here is the code:</p>
  
  <pre><code>&lt;Style x:Key="Align" TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource {x:Type DataGridCell}}"&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type DataGridCell}"&gt;
                  &lt;Grid Background="{TemplateBinding Background}"&gt;
                      &lt;ContentPresenter HorizontalAlignment="{Binding Converter={StaticResource SmartAlignmentConverter}}"/&gt;
                  &lt;/Grid&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>The problem is that the converter sends in the row object, rather than the cell. As in, the entire object that contains the row's variables is sent in, so there's no usable info about which specific cell is being aligned. I need some way to send in the cell's value specifically.</p>
  
  <p>UPDATE:</p>
  
  <p>I've managed to send in the cell itself, which is a step in the right direction. </p>
  
  <pre><code>Binding="{Binding RelativeSource={RelativeSource self}, Converter={StaticResource SmartAlignmentConverter}}" 
  </code></pre>
  
  <p>But the problem has become that there's no information inside of the cell. It's content is null when it's sent to the converter. I don't suppose there's a way to send the thing to the converter after it's been filled with information?</p>