I have a ListBox, a Show Button, and a TextBlock in my Windows Phone application.
Whenever the user clicks on the Show Button, an item from the ListBox
should be shown in TextBlock. If the user clicks on Show Button again, the next item should be shown.
XAML
<ListBox x:Name="FavoriteListBox"
SelectionChanged="FavoriteListBox_SelectionChanged"
ItemContainerStyle="{StaticResource CustomListBoxItemStyle}"
Height="300" Width="250">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock x:Name="FavoriteListBoxTextBlock"
FontSize="40" FontWeight="SemiBold"
Text="{Binding AnswerName}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock x:Name="DisplayTextBlock"/>
<Button x:Name="ShowButton" Click="ShowButton_Click"/>
C#
private void ShowButton_Click(object sender, EventArgs e)
{
if(FavoriteListBox != null)
{
// ??????
}
}
How can achieve such functionality?