title: Use a WPF Style to simplify repetitive MultiBindings
body: <p>I am displaying the results of several tests. There are 2 variables on each test, and the text and color of the displayed results vary with both. I have this working, but there's a lot of repetitive MultiBinding going on, and I'd like to see if there's a way to use a Style to simplify the XAML.</p>
  
  <p>Here's a simplified look at what my code looks like:</p>
  
  
  
  <pre class="lang-cs prettyprint-override"><code>//TestResults.cs excerpt
  public class TestResults
  {
      private Test1Result test1 = new Test1Result();
      public Test1Result Test1 { get { return test1; } }
  
      private Test2Result test2 = new Test2Result();
      public Test2Result Test2 { get { return test2; } }
  }
  
  //TestCtrl.xaml.cs excerpt
  public class TestCtrl : UserControl
  {
      private TestResults results = new TestResults();
      public TestResults Results { get { return results; } }
  }
  </code></pre>
  
  
  
  <pre><code>&lt;!-- TestCtrl.xaml excerpt --&gt;
  &lt;UserControl x:Class="Tester.TestCtrl" x:Name="TestResultsCtrl" ...&gt;
  
  &lt;!-- lots of stuff --&gt;
  
  &lt;TextBlock Grid.Row="6"&gt;
      &lt;TextBlock.Text&gt;
          &lt;MultiBinding Converter="{StaticResource TestToTextConverter}" &gt;
              &lt;Binding Path="Results.Test1.Temperature" ElementName="TestResultsCtrl" /&gt;
              &lt;Binding Path="Results.Test1.Time" ElementName="TestResultsCtrl" /&gt;
          &lt;/MultiBinding&gt;
      &lt;/TextBlock.Text&gt;
      &lt;TextBlock.Foreground&gt;
          &lt;MultiBinding Converter="{StaticResource TestToBrushConverter}"&gt;
              &lt;Binding Path="Results.Test1.Temperature" ElementName="TestResultsCtrl" /&gt;
              &lt;Binding Path="Results.Test1.Time" ElementName="TestResultsCtrl" /&gt;
          &lt;/MultiBinding&gt;
      &lt;/TextBlock.Foreground&gt;
  &lt;/TextBlock&gt;
  
  &lt;TextBlock Grid.Row="7"&gt;
      &lt;TextBlock.Text&gt;
          &lt;MultiBinding Converter="{StaticResource TestToTextConverter}" &gt;
              &lt;Binding Path="Results.Test2.Temperature" ElementName="TestResultsCtrl" /&gt;
              &lt;Binding Path="Results.Test2.Time" ElementName="TestResultsCtrl" /&gt;
          &lt;/MultiBinding&gt;
      &lt;/TextBlock.Text&gt;
      &lt;TextBlock.Foreground&gt;
          &lt;MultiBinding Converter="{StaticResource TestToBrushConverter}"&gt;
              &lt;Binding Path="Results.Test2.Temperature" ElementName="TestResultsCtrl" /&gt;
              &lt;Binding Path="Results.Test2.Time" ElementName="TestResultsCtrl" /&gt;
          &lt;/MultiBinding&gt;
      &lt;/TextBlock.Foreground&gt;
  &lt;/TextBlock&gt;
  
  &lt;!-- lots more repetitions here --&gt;
  </code></pre>
  
  <p>I would like to define a Style so that I can apply the MultiBindings to the TextBlocks more easily. The only difference in each one is which test I specify in the Binding Path values. My goal would be something like:</p>
  
  <pre><code>&lt;Style x:Key="TestResultsStyle" TargetType="{x:Type TextBlock}"&gt;
      &lt;!-- do binding stuff here --&gt;
  &lt;/Style&gt;
  
  &lt;TextBlock Grid.Row="6" 
      Style="{StaticResource TestResultsStyle}" &lt;!--set Test1 path here --&gt; /&gt;
  &lt;TextBlock Grid.Row="7" 
      Style="{StaticResource TestResultsStyle}" &lt;!--set Test2 path here --&gt; /&gt;
  </code></pre>
  
  <p>Is anything similar to this possible?</p>