title: Using interaction trigger to call visibility changed method WPF
body: <p>What I would like to figure out is two things, how to get a trigger occurring when a user control's visibility is changed and passing the value of visibility through as a parameter.</p>
  
  <p>For whatever reason the trigger doesn't seem to be firing. I have only just added in the ControlVisible parameter to show what I would like to happen, when testing it was not there and just had a messagebox inside to catch when visibility changed, as in the commented out method.</p>
  
  <p>I am using 4.0 with Visual Studio 2010</p>
  
  <p>Main Window View which contains the user control</p>
  
  <pre><code>&lt;Window x:Class="bt.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          xmlns:vm="clr-namespace:bt"
          xmlns:ctrls="clr-namespace:bt.Controls"
          xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
          xmlns:ei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
          mc:Ignorable="d"&gt;
  
      &lt;Grid&gt;
          &lt;ctrls:Login Visibility="{Binding DataContext.Vis,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window},Converter={StaticResource BooleanToVisibilityConverter}}" &gt;
              &lt;i:Interaction.Triggers&gt;
                  &lt;i:EventTrigger EventName="IsVisibleChanged"&gt;
                      &lt;ei:CallMethodAction MethodName="VisibleTrigger" /&gt;
                  &lt;/i:EventTrigger&gt;
              &lt;/i:Interaction.Triggers&gt;
          &lt;/ctrls:Login&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>UserControl View Model:</p>
  
  <pre><code>namespace bt.Controls
  {
      class LoginViewModel
      {
          public LoginViewModel()
          {
          }
  
          public void VisibleTrigger(bool ControlVisible)
          {
              if (ControlVisible)
              {
                  MessageBox.Show("Start timer");
              }
              else
              {
                  MessageBox.Show("Stop timer");
              }
          }
  
          //public void VisibleTrigger()
          //{
          //    MessageBox.Show("Changed");
          //}
      }
  }
  </code></pre>