title: Accessing controls in ItemsControl
body: <p>I am creating a WPF application. I want a page to be displayed on each button click. </p>
  
  <pre><code> &lt;ItemsControl ItemsSource="{Binding Path=DashBoardApps}" VerticalAlignment="Bottom" HorizontalAlignment="Center" Name="Abc"&gt;
              &lt;ItemsControl.ItemsPanel&gt;
                  &lt;ItemsPanelTemplate&gt;
                      &lt;Controls:FishEyeControl /&gt;
                  &lt;/ItemsPanelTemplate&gt;
              &lt;/ItemsControl.ItemsPanel&gt;
              &lt;ItemsControl.ItemTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;StackPanel Orientation="Horizontal"&gt;
                          &lt;Button MouseDown="Button_MouseDown"&gt;
                              &lt;Image  Source="{Binding Path=ApplicationImage}" Width="32" Height="32"/&gt;
                          &lt;/Button&gt;
                          &lt;TextBlock x:Name="txtAppName" Text="{Binding Path=ApplicationName}" TextAlignment="Center" Visibility="Hidden" FontSize="7px" Foreground="#eff7ff" VerticalAlignment="Center"/&gt;
                      &lt;/StackPanel&gt;
                      &lt;DataTemplate.Triggers&gt;
                          &lt;Trigger Property="IsMouseOver" Value="True"&gt;
                              &lt;Setter TargetName="txtAppName" Property="Visibility" Value="Visible" /&gt;
                          &lt;/Trigger&gt;
                      &lt;/DataTemplate.Triggers&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ItemsControl.ItemTemplate&gt;
          &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>There are 6 buttons in total.On the button click I want a page to be displayed.(different pages for different buttons).
  In the code behind I've done something like this</p>
  
  <pre><code>private void Button_MouseDown(object sender, MouseButtonEventArgs e)
      {
          var s = sender as ItemsControl;
          if (s == Abc.Items.GetItemAt(1))//if it is the first button. Not sure if it is right
          {
             //Code to display page
          }
  
      }
  </code></pre>
  
  <p>I want to know which button generated the event. As in, if the first button was clicked then page1 has to be displayed. So I tried using <code>GetItemAt()</code> function to see if the first button was clicked(to display the first page). However it doesn't work and I am not sure if this approach is correct.</p>
  
  <p>P.S Simply stated I want to know which button generated the event-Can this be done using index. If so, how?
  Kindly help</p>