title: XAML Buttons in ListBoxItem template
body: <p>I have a ListBox that has a single select. When item is selected it should show additional options like - edit, delete buttons.</p>
  
  <p>So i have done this:</p>
  
  <pre><code>&lt;ListBox ItemContainerStyle="{StaticResource MyItemStyle}" Loaded="MyList_Loaded"&gt;
  
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>And here is my template:</p>
  
  <pre><code>&lt;Style x:Key="MyItemStyle" TargetType="ListBoxItem"&gt;
          &lt;!--Deleted to minimize the snippet--&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="ListBoxItem"&gt;
                      &lt;Grid x:Name="LayoutRoot" BorderThickness="0,1,0,0" BorderBrush="Black" Background="{TemplateBinding Background}"&gt;
                          &lt;VisualStateManager.VisualStateGroups&gt;
                              &lt;VisualStateGroup x:Name="CommonStates"&gt;
                                  &lt;!--Deleted to minimize the snippet--&gt;
                                  &lt;VisualState x:Name="Selected"&gt;
                                      &lt;Storyboard&gt;
                                          &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="EditButtons"&gt;
                                              &lt;DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/&gt;
                                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                                      &lt;/Storyboard&gt;
                                  &lt;/VisualState&gt;
                                  &lt;!--Deleted to minimize the snippet--&gt;
                              &lt;/VisualStateGroup&gt;
                          &lt;/VisualStateManager.VisualStateGroups&gt;
                          &lt;Rectangle x:Name="PressedBackground" Grid.RowSpan="2" Fill="Transparent" Control.IsTemplateFocusTarget="True"/&gt;
                          &lt;ContentPresenter x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" HorizontalAlignment="Stretch" Style="{StaticResource BodyContentPresenterStyle}" TextWrapping="NoWrap" VerticalAlignment="Stretch"/&gt;
                          &lt;Grid Grid.Row="1" HorizontalAlignment="Right" Margin="13,0,13,13" Visibility="Collapsed" x:Name="EditButtons"&gt;
                              &lt;Grid.ColumnDefinitions&gt;
                                  &lt;ColumnDefinition Width="auto"/&gt;
                                  &lt;ColumnDefinition Width="auto"/&gt;
                                  &lt;ColumnDefinition Width="auto"/&gt;
                              &lt;/Grid.ColumnDefinitions&gt;
                              &lt;HyperlinkButton 
                                  x:Name="SendButton" 
                                  VerticalAlignment="Center"
                                  IsTabStop="True"
                                  TabIndex="3"
                                  Margin="7,0,0,0"
                                  Content="Send" 
                                  Style="{StaticResource HyperlinksStyle}" 
                                  /&gt;
                              &lt;HyperlinkButton 
                                  x:Name="EditButton" 
                                  VerticalAlignment="Center"
                                  IsTabStop="True"
                                  TabIndex="3"
                                  Grid.Column="1"
                                  Margin="7,0,0,0"
                                  Content="Edit" 
                                  Style="{StaticResource HyperlinksStyle}" 
                                  /&gt;
                              &lt;HyperlinkButton 
                                  x:Name="DeleteButton" 
                                  VerticalAlignment="Center"
                                  IsTabStop="True"
                                  TabIndex="3"
                                  Grid.Column="2"
                                  Margin="7,0,0,0"
                                  Content="Delete" 
                                  Style="{StaticResource HyperlinksStyle}" 
                                  /&gt;
                          &lt;/Grid&gt;
                      &lt;/Grid&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p>I cant figure out how can i bind Click handlers to those 3 hyperlink buttons.
  I have tried to:</p>
  
  <pre><code>private void MyList_Loaded(object sender, RoutedEventArgs e)
  {
      var sendButton = FindChild&lt;HyperlinkButton&gt;(MyList, "SendButton");
  }
  </code></pre>
  
  <p>And</p>
  
  <p>Adding a handler directly in XAML from visual editor.</p>
  
  <p><strong>But all this didn't work. How can i react to click events of those 3 buttons?</strong></p>