【问题标题】:How to set item some as selected, that was selected before of LongListMultiSelector如何将某些项目设置为已选择,在 LongListMultiSelector 之前已选择
【发布时间】:2015-11-26 15:24:03
【问题描述】:

我正在使用 wpToolkit 的 LongListMultiSelector。

我想从不同的专辑中选择不同的歌曲。

  1. 首先进入“专辑1”页面选择“歌曲1”、“歌曲2”。
  2. 回到专辑列表页面。
  3. 再次转到同一张专辑“专辑 1”页面。

我想在尝试选择一个之前向用户显示“歌曲 1”、“歌曲 2”已被选中。但如果用户回到同一张专辑,我无法标记以前选择的歌曲。

有什么办法吗。

【问题讨论】:

  • @TomWuyts 抱歉,这对我没有帮助。
  • 您尝试将“歌曲”添加回 LongListMultiSelector 上可用的 .SelectedItems 集合?换句话说,您能否向我们展示一些您尝试过和无效的代码?

标签: c# xaml windows-phone-8.1 silverlight-5.0


【解决方案1】:

检查所选歌曲列表与专辑歌曲。然后像这样添加到 lls 中。

llms.ItemsSource = this.mediaCollection;

int i = 0;
foreach (StorageFile file in SongList) //SongList of the album
{
    var thumb = await GetThumbImage(file, ThumbnailMode.MusicView, 150);

    var songItem = new songModel() { StorageFile = file, ThumbImage = thumb };//songModel is a song class
    this.mediaCollection.Add(songItem); 

    if (MultiplePhoto.Instance.SongItems.Count > 0) //SongItems contains the selected songlist
       if (MultiplePhoto.Instance.SongItems.FirstOrDefault(x => x.StorageFile.Path == songItem.StorageFile.Path) != null) // check that is currently added song selected?
          llms.SelectedItems.Add(this.mediaCollection[i]); //here addd the selected item to the lls
    i++;
}

【讨论】:

    猜你喜欢
    • 2012-10-31
    • 1970-01-01
    • 2013-12-12
    • 1970-01-01
    • 2021-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-09
    相关资源
    最近更新 更多