1. badshar's Avatar
    The following is my XAML code:

    <DataTemplate x:Key="GroupTemplate">
    <Grid Grid.Column="1">
    <StackPanel Grid.Column="1">
    <TextBlock x:Name="SongTitle" Text="{Binding Title}"
    Style="{ThemeResource ListViewItemTextBlockStyle}"/>
    <TextBlock x:Name="ArtistName" Text="{Binding Album}"
    Style="{ThemeResource ListViewItemContentTextBlockStyle}"/>

    <CollectionViewSource x:Name="MusicSource" IsSourceGrouped="true" />

    <DataTemplate x:Key="headerTemplate">
    <StackPanel HorizontalAlignment="Stretch" Width="{Binding ActualWidth, ElementName=contentList}">
    <TextBlock Text="{Binding Key}" />

    ItemsSource="{Binding Source={StaticResource MusicSource}}"
    ItemTemplate="{StaticResource GroupTemplate}">
    <GroupStyle HidesIfEmpty="True" HeaderTemplate="{StaticResource headerTemplate}"/>
    x:Name="Search" TextChanged="TextBox_TextChanged" />

    The following is the C# code behind it:

    // imports

    namespace Test
    public sealed partial class Player : Page
    ObservableCollection<Music> source = new ObservableCollection<Music>();
    List<AlphaKeyGroup<Music>> itemSource;

    public Player()

    private async Task getMusic(IStorageFolder folder)
    var folders = await folder.GetFoldersAsync();
    if (folders != null)
    foreach (var fol in folders)
    await getMusic(fol);

    var files = await folder.GetFilesAsync();
    foreach (var file in files)
    MusicProperties musicProperties = await file.Properties.GetMusicPropertiesAsync();
    this.source.Add(new Music(musicProperties.Artist, musicProperties.Title, musicProperties.Album));
    itemSource = AlphaKeyGroup<Music>.CreateGroups(source, CultureInfo.CurrentUICulture, s => s.Artist, true);
    this.MusicSource.Source = itemSource;

    public async void SetItemSource()
    await getMusic(Windows.Storage.KnownFolders.MusicLibrary);

    private void TextBox_TextChanged(object sender, TextChangedEventArgs e)


    As the user types in the textbox, the listview should automatically scroll to the matching group.

    The groups are based on Artist, so it's like:

    Michael Jackson
    - Song 1
    - Song 2

    - Song 1
    - Song 2

    So if I type "Em", the listview should immediately scroll down to the second group, since that artist "Eminem" comes closest to "Em".

    Is this possible?

    I am using the AlphaKeyGroup class.
    08-26-2014 10:25 PM
  2. luke_f's Avatar
    The ListView has a method ScrollIntoView() which allows you to scroll to a specific item within the list. You can set the second parameter to "Leading", mening that the item shall be scrolled to the top of the list. However, I *think* this only works for the items (tracks in your case) and not for the groups. You could try it with the groups, but if it does not work, try to scroll the first track of the group into view. Hope this helps.
    10-16-2014 12:14 PM
  3. Catholic Tech Geek's Avatar
    Yes, this is possible. First, you need a collection of all of the "headers" of each group. Next, when the text changes, you need to search for the first match to what is in the search box within this collection of group headers. Lastly, get the matching group and use the ScrollIntoView() function of the ListView to scroll to the first member of the matching group.
    10-18-2014 03:30 PM

Similar Threads

  1. My Quick reply to PM not in my inbox
    By BarryII in forum Site Feedback & Help
    Replies: 3
    Last Post: 08-27-2014, 11:53 AM
  2. Replies: 0
    Last Post: 08-26-2014, 10:04 PM
  3. Lumia Cyan For Lumia 620 In SaudiArabia Released
    By Radwan126 in forum Windows Phones
    Replies: 0
    Last Post: 08-26-2014, 09:40 PM
  4. New phone doesn't recognize old apps on SD card
    By Z10YkakPES in forum Ask a Question
    Replies: 0
    Last Post: 08-26-2014, 09:37 PM
  5. Replies: 0
    Last Post: 08-26-2014, 09:24 PM