Here is a sample... use this...hope it helps...
<listbox x:name="TeamListbox" horizontalalignment="Left" height="Auto" verticalalignment="Top" width="Auto" style="{StaticResource ListBoxStyle1}" itemtemplate="{StaticResource DataTemplate1}" xmlns:x="#unknown">
</listbox>
The definitions for datatemplate is
<phone:phoneapplicationpage.resources xmlns:phone="#unknown">
<datatemplate x:key="DataTemplate2" xmlns:x="#unknown">
<grid>
<textblock margin="0,0,1,0" fontsize="25" foreground="Green" fontweight="SemiBold" textwrapping="Wrap" text="{Binding }" d:layoutoverrides="Width, Height" xmlns:d="#unknown" />
</grid>
</datatemplate>
<datatemplate x:key="DataTemplate1" xmlns:x="#unknown">
<stackpanel>
<textblock margin="0,0,1,0" fontsize="32" foreground="White" fontweight="Bold" textwrapping="Wrap" text="{Binding TeamName}" d:layoutoverrides="Width, Height" tap="TextBlock_Tap" xmlns:d="#unknown" />
<listbox x:name="InnerLsitbox" tag="{Binding TeamName}" itemtemplate="{StaticResource DataTemplate2}" itemssource="{Binding TeamMembers}" visibility="Collapsed" />
</stackpanel>
</datatemplate>
</phone:phoneapplicationpage.resources>
In code-behind,
define your own class
public class Teams
{
public string TeamName { get; set; }
public List<string> TeamMembers { get; set; }
}
</string>
Initilalise the collection and fill with some dummy data
ObservableCollection<teams> teams ;
private FrameworkElement expandedElement;
public MainPage()
{
InitializeComponent();
teams = new ObservableCollection<teams>();
InitializeTeams();
TeamListbox.ItemsSource = teams;
}
public void InitializeTeams()
{
teams.Add(new Teams() { TeamName = "India", TeamMembers= new List<string> () { "aaaaa1", "sssssssss1", "ddddd1", "fffffffffff1", "zzzzzzz1", "ccccc1" } });
teams.Add(new Teams() { TeamName = "Australia", TeamMembers = new List<string>() { "aaaaa2", "sssssssss2", "ddddd2", "fffffffffff2", "zzzzzzz2", "ccccc2" } });
teams.Add(new Teams() { TeamName = "Srilanka", TeamMembers = new List<string>() { "aaaaa3", "sssssssss3", "ddddd3", "fffffffffff3", "zzzzzzz3", "ccccc3" } });
teams.Add(new Teams() { TeamName = "South Africa", TeamMembers = new List<string>() { "aaaaa4", "sssssssss4", "ddddd4", "fffffffffff4", "zzzzzzz4", "ccccc4" } });
teams.Add(new Teams() { TeamName = "England", TeamMembers = new List<string>() { "aaaaa5", "sssssssss5", "ddddd5", "fffffffffff5", "zzzzzzz5", "ccccc5" } });
teams.Add(new Teams() { TeamName = "West Indies", TeamMembers = new List<string>() { "aaaaa6", "sssssssss6", "ddddd6", "fffffffffff6", "zzzzzzz6", "ccccc6" } });
}
</string></string></string></string></string></string></teams></teams>
In the tap event, handle the visibility of innerListbox like this
private void TextBlock_Tap(object sender, GestureEventArgs e)
{
if (expandedElement != null)
(expandedElement as ListBox).Visibility = System.Windows.Visibility.Collapsed;
ListBox ll = (((sender as TextBlock).Parent as StackPanel).Children[1] as ListBox);
expandedElement = ll;
ll.Visibility = System.Windows.Visibility.Visible;
}