title: WPF: How to reference other controls within trigger Property property?
body: <p>I have a WPF page. Page has some content, but the last child component of page's root layout is a user control that I have created. It looks like this: </p>
  
  <pre><code>&lt;UserControl DataContext=UserControlViewModel&gt;
    &lt;UserControl.Resources&gt;
      &lt;BooleanToVisibilityConverter x:Key="visibilityConverter" /&gt;
    &lt;/UserControl.Resources&gt;
    &lt;Grid 
        Name="grid" 
        Visibility="{Binding IsOn, Converter={StaticResource visibilityConverter}}"&gt;
      &lt;!-- Border to dim everything behind my user control --&gt;
      &lt;Border Background="#000000" Opacity="0.4" /&gt;
      &lt;!-- The following border is red and holds the content --&gt;
      &lt;Border 
          Width="{Binding ElementName=txt, Path=ActualWidth}" 
          Height="{Binding ElementName=txt, Path=ActualHeight}" 
          Margin="{Binding ElementName=txt, Path=Margin}" 
          HorizontalAlignment="{Binding ElementName=txt, Path=HorizontalAlignment}" 
          VerticalAlignment="{Binding ElementName=txt, Path=VerticalAlignment}" 
          Background="Red"&gt;
        &lt;TextBlock 
            Name="txt"
            Width="200" 
            Height="100" 
            Margin="20" 
            HorizontalAlignment="Center" 
            VerticalAlignment="Center" 
            Text="This is my super awesome message!" /&gt;
      &lt;/Border&gt;
    &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>By default, the <code>IsOn</code> property of the <code>UserControlViewModel</code> object is set to <code>false</code>, i.e. the user control is not visible. I have implemented some logic that changes this property to <code>true</code> and then the user control is displayed in front of all other components which are dimmed. This works well. </p>
  
  <p>Now, I want to create a fade effect animation which would dim the components that are behind the user control once it becomes visible. Next, I want to make my red border that holds the content to fade in from the left hand side, so moving + fade. </p>
  
  <p>Let's start with the fade effect first. I wrote this style to the <code>Border</code> that is supposed to do the dimming of background components: </p>
  
  <pre><code>&lt;UserControl DataContext=UserControlViewModel&gt;
    &lt;UserControl.Resources&gt;
      &lt;BooleanToVisibilityConverter x:Key="visibilityConverter" /&gt;
    &lt;/UserControl.Resources&gt;
    &lt;Grid 
        Name="grid"
        Visibility="{Binding IsOn, Converter={StaticResource visibilityConverter}}"&gt;
      &lt;!-- Border to dim everything behind my user control --&gt;
      &lt;Border Background="#000000" Opacity="0.4"&gt;
        &lt;!-- The following style is new code --&gt;
        &lt;Border.Style&gt;
          &lt;Style TargetType="Border"&gt;
            &lt;Style.Triggers&gt;
              &lt;Trigger Property="{Binding ElementName=grid, Visibility}" Value="Visible"&gt;
                &lt;Trigger.EnterActions&gt;
                  &lt;BeginStoryboard&gt;
                    &lt;Storyboard&gt;
                      &lt;DoubleAnimation 
                          Storyboard.TargetProperty="Opacity" 
                          From="0.0" 
                          To="0.4" 
                          Duration="0:0:1" /&gt;
                    &lt;/Storyboard&gt;
                  &lt;/BeginStoryboard&gt;
                &lt;/Trigger.EnterActions&gt;
              &lt;/Trigger&gt;
            &lt;/Style.Triggers&gt;
          &lt;/Style&gt;
        &lt;/Border.Style&gt;
      &lt;/Border&gt;
      ...
  </code></pre>
  
  <p>But there's the problem: I cannot set the binding on the trigger <code>Property</code>, because it is not a dependency property. I need a way to tell my trigger to fire once the <code>grid</code> has got the <code>Visibility</code> property set to <code>Visible</code>. Please help and thank you!</p>
  
  <p>Second problem is, I don't know how to do the moving of the red border, so I need help around some scale transformations as well, I guess... Thanks once again!</p>