title: How to dynamically change a PATH DATA property at runtime in XAML?
body: <p>I have a button with a custom ControlTemplate. During execution, I want to change the PathGeometry and Fill based on criteria the user selects.</p>
  
  <p>In a ResourceDictionary I have two PathGeometry definitions:</p>
  
  <pre><code>&lt;PathGeometry x:Key="Card" &gt;
      &lt;PathFigure StartPoint="0,0" &gt;
          &lt;LineSegment Point="0,50"/&gt;
          &lt;LineSegment Point="100,50"/&gt;
          &lt;LineSegment Point="100,20"/&gt;
          &lt;LineSegment Point="80,0"/&gt;
          &lt;LineSegment Point="0,0"/&gt;
      &lt;/PathFigure&gt;
  &lt;/PathGeometry&gt;
  </code></pre>
  
  <p>and </p>
  
  <pre><code>&lt;PathGeometry x:Key="Triangle" &gt;
      &lt;PathFigure StartPoint="0,0" &gt;
          &lt;LineSegment Point="50,50"/&gt;
          &lt;LineSegment Point="100,0"/&gt;
          &lt;LineSegment Point="0,0"/&gt;
      &lt;/PathFigure&gt;
  &lt;/PathGeometry&gt;
  </code></pre>
  
  <p>In the same ResourceDictionary I have a Style defined:</p>
  
  <pre><code>&lt;Style x:Key="ButtonStyle" TargetType="{x:Type Button}"&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type Button}"&gt;
                  &lt;Grid x:Name="grid"  Background="White"&gt;
                      &lt;Path Stroke="Black" StrokeThickness="2" Data="{DynamicResource Card}"&gt; 
                          &lt;Path.Style&gt;
                              &lt;Style TargetType="Path"&gt;
                                  &lt;Style.Triggers&gt;
                                      &lt;DataTrigger
                                          Binding="{Binding HatchType, 
                                          RelativeSource={RelativeSource FindAncestor, AncestorType=local:PullArrowConnector}, 
                                          Mode=TwoWay}" Value="Withdrawal"&gt;
                                          &lt;Setter Property="Fill" Value="{DynamicResource HatchBrush}" /&gt;
                                      &lt;/DataTrigger&gt;
                                      &lt;DataTrigger
                                          Binding="{Binding HatchType, 
                                          RelativeSource={RelativeSource FindAncestor, AncestorType=local:PullArrowConnector}, 
                                          Mode=TwoWay}" Value="Production"&gt;
                                          &lt;Setter Property="Fill" Value="Transparent" /&gt;
                                      &lt;/DataTrigger&gt;
                                      &lt;DataTrigger
                                          Binding="{Binding HatchType, 
                                          RelativeSource={RelativeSource FindAncestor, AncestorType=local:PullArrowConnector}, 
                                          Mode=TwoWay}" Value="Signal"&gt;
                                          &lt;Setter Property="Path.Data" Value="{DynamicResource Triangle}" /&gt;
                                          &lt;Setter Property="Fill" Value="Transparent" /&gt;
                                      &lt;/DataTrigger&gt;
                                  &lt;/Style.Triggers&gt;
                              &lt;/Style&gt;
                          &lt;/Path.Style&gt;
                      &lt;/Path&gt;
                  &lt;/Grid&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>Using a <strong>DataTrigger</strong>, I'm able to dynamically control the <strong>Fill</strong> property, but not the <strong>Data</strong> property. I understand that <strong>Data</strong> is not a property of <strong>Path.Style</strong>, but its not clear to me how I can dynamically change the <strong>PathGeometry</strong> at runtime. The third <strong>DataTrigger</strong> shown above where I try to set the <strong>Path.Data</strong> property doesn't work.</p>