title: How to get the caller of a WPF Converter?
body: <p>I try to get the element which calls a converter in it's Convert function.</p>
  
  <p>The reason is, that I've got a style for TreeViewItems, and want to Bind the BackgroundColor to the Content(If there are subitems or not). Therefore I need the Converter, who needs to know what the correspondenting Item contains, and in my opinion therefore it's needet that he nows his caller.</p>
  
  <p>Here my Style:</p>
  
  <pre><code>        &lt;Style TargetType="{x:Type TreeViewItem}"&gt;
          &lt;Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" /&gt;
          &lt;Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" /&gt;
          &lt;Setter Property="Background" Value="Transparent"/&gt;
          &lt;Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/&gt;
          &lt;Setter Property="Padding" Value="1,0,0,0"/&gt;
          &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/&gt;
          &lt;Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}"/&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{x:Type TreeViewItem}"&gt;
                      &lt;StackPanel&gt;
                          &lt;Border Name="Bd" Background="{TemplateBinding Background, Converter={StaticResource NodeBackgroundConverter}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"&gt;
                              &lt;Grid Margin="{Binding Converter={StaticResource lengthConverter},
                                                             RelativeSource={RelativeSource TemplatedParent}}"&gt;
                                  &lt;Grid.ColumnDefinitions&gt;
                                      &lt;ColumnDefinition Width="19" /&gt;
                                      &lt;ColumnDefinition /&gt;
                                  &lt;/Grid.ColumnDefinitions&gt;
                                  &lt;ToggleButton x:Name="Expander"
                                                        Style="{StaticResource ExpandCollapseToggleStyle}"
                                                        IsChecked="{Binding Path=IsExpanded,
                                                        RelativeSource={RelativeSource TemplatedParent}}"
                                                        ClickMode="Press"/&gt;
                                  &lt;ContentPresenter x:Name="PART_Header"
                                                            Grid.Column="1"
                                                            ContentSource="Header"
                                                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/&gt;
                              &lt;/Grid&gt;
                          &lt;/Border&gt;
                          &lt;ItemsPresenter x:Name="ItemsHost"/&gt;
                      &lt;/StackPanel&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p>The Question is now how to do this, using the "NodeBackgroundConverter".</p>
  
  <p>Thx</p>