I have listbox like this:
<ListBox Height="589" HorizontalAlignment="Left" Name="AllNotesListBox" VerticalAlignment="Top" Width="460" SelectionChanged="AllNotesListBox_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<Button Width="460" Height="150" DoubleTap="Button_DoubleTap">
<Button.Content>
<StackPanel Width="460" Orientation="Horizontal" Height="120">
<Image Source="/SimpleNote;component/Images/note.png" Width="60" Height="60"></Image>
<!-->Code for title looks<-->
<StackPanel Orientation="Horizontal" Height="80">
<TextBlock Text="Title: "></TextBlock>
<TextBlock Text="{Binding title}"></TextBlock>
</StackPanel>
</StackPanel>
</Button.Content>
</Button>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
And now in function Button_DoubleTap I want to have title that is on the button that user clicked. How I can do that?
Bind the
Tagproperty of theButton, like this:And then you can read it out in your
Button_DoubleTapmethod: