title: How to change the visibility when the click is outside of the control
body: <p>I have a User control in WPF that is built on MVVM format. The usercontrol is a collection of viewmodels arranged in a panel. The number of pannels (or related views/ view models) will be decided at run time.</p>
  
  <p>Each panel is a user control and refers a view model (case as workspaces). Each pannel consists of a button and a listbox. Initially when loaded only the buttons of all the pannels will be shown. On click of button the corresponding List box would be shown. Till this it is working fine.</p>
  
  <p>What i need is if the user clicks on any other area the curent open listbox should collapse. If user selects another button, that listbox should be shown and this current open list box should be collapsed.</p>
  
  <p>Currently it shows on button click but never closes</p>
  
  <p>For showing the list box i am using the below code in the button trigger :</p>
  
  <pre><code>&lt;Button.Triggers&gt;
              &lt;EventTrigger RoutedEvent="Button.Click"&gt;
                  &lt;BeginStoryboard&gt;
                      &lt;Storyboard&gt;
                          &lt;ObjectAnimationUsingKeyFrames Storyboard.Target="{x:Reference ListBoxDrop}" 
                                                 Storyboard.TargetProperty="Visibility"&gt;
                              &lt;DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}"&gt;
                              &lt;/DiscreteObjectKeyFrame&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                      &lt;/Storyboard&gt;
                  &lt;/BeginStoryboard&gt;
              &lt;/EventTrigger&gt;
          &lt;/Button.Triggers&gt;
  </code></pre>
  
  <p>Any suggestion ?</p>
  
  <ul>
  <li>Girija</li>
  </ul>