Windows Phone中的自定义跳转列表



我一直在看这个:http://code.msdn.microsoft.com/wpapps/Custom-LongList-Selector-bf8cb9ad并试图合并到我的应用程序。然而,它有点混乱,因为我的数据加载不同。现在,我有两个错误的最佳重载方法匹配CustomKeyGroup<.ViewModels.SoundData>.GetSoundGroups(System.Collections.Generic.List<.ViewModels.SoundData>)'有一些无效的参数

参数1:不能从'string'转换为'System.Collections.Generic.List'

在mainpage.cs中的'CustomKeyGroup.GetSoundGroups(mvm.Items);'错误。我知道物品是个问题。如果你看一下链接,它们加载数据的方式是不同的。

我知道有些事情搞砸了大时间,但由于我的数据加载不同,我努力使它正确工作。

我想在我的SoundModel中有自定义跳跃列表,包括组(Alpha, Bravo等)的头部。这是一个部分:

namespace T.ViewModels
{
    public class SoundModel: BindableBase
    {
        public SoundGroup NewAdds { get; set; }
        public SoundGroup Software { get; set; }
        }
        public bool IsDataLoaded { get; set; }

        public void LoadData()
        {
            // Load data into the model
            Software = CreateSoftwareGroup();
            NewAdds = CreateNewAddsGroup();

            IsDataLoaded = true;
        }
        private SoundGroup CreateNewAddsGroup()
        {
            SoundGroup data = new SoundGroup();
            data.Title = "New";
            string basePath = "assets/audio/newadds/";
               data.Items.Add(new SoundData
            {
                Title = "Test1",
                FilePath = basePath + "Test.mp3",
                Groups = "Alpha"
            });

            data.Items.Add(new SoundData
            {
                Title = "Test2",
                FilePath = basePath + "Test2.mp3",
                Groups="Bravo"
            });

            data.Items.Add(new SoundData
            {
                Title = "Test3",
                FilePath = basePath + "Test3.mp3",
                Groups= "Zulu"
            });
  private SoundGroup CreateSoftwareGroup()
        {
            SoundGroup data = new SoundGroup();
            data.Title = "Software";
            string basePath = "assets/audio/Software/";
            data.Items.Add(new SoundData
            {
                Title = "Test1",
                FilePath = basePath + "Test.mp3",
                Groups = "Alpha"
            });
            data.Items.Add(new SoundData
            {
                Title = "Test2",
                FilePath = basePath + "Test2.mp3",
                Groups="Bravo"
            });

            data.Items.Add(new SoundData
            {
                Title = "Test3",
                FilePath = basePath + "Test3.mp3",
                Groups= "Zulu"
            });

这是相关的mainpage.cs:

SoundData mvm = new SoundData();
            this.LongList.ItemsSource = CustomKeyGroup<SoundData>.GetSoundGroups(mvm.Items);

SoundGroup:

{
    public class SoundGroup
    {
        public SoundGroup()
        {
            Items = new List<SoundData>();
        }
        public List<SoundData> Items { get; set; }
        public string Title { get; set; }
        public string Groups { get; set; }
    }
}

SoundData:

{
    public class SoundData : ViewModelBase
    {
        public string Title { get; set; }
        public string FilePath { get; set; }
        public string Items { get; set; }
        public string Groups { get; set; }

        public RelayCommand<string> SaveSoundAsRingtone { get; set; }

        private void ExecuteSaveSoundAsRingtone(string soundPath)
        {
            App.Current.RootVisual.Dispatcher.BeginInvoke(() =>
            {
                SaveRingtoneTask task = new SaveRingtoneTask();
                task.Source = new Uri("appdata:/" + this.FilePath);
                task.DisplayName = this.Title;
                task.Show();
            }
                );
        }   
        public SoundData()
        {
            SaveSoundAsRingtone = new RelayCommand<string>(ExecuteSaveSoundAsRingtone);
        }
    }
}

到目前为止,我可以看到你应该调用函数如下

SoundModel svm = new SoundModel();
svm.LoadData();
this.LongList.ItemsSource = CustomKeyGroup<SoundData>.GetSoundGroups(svm.Software.Items);

this.LongList.ItemsSource = CustomKeyGroup<SoundData>.GetSoundGroups(svm.NewAdds.Items);

原因是您需要在方法GetSoundGroups中传递Generic.List<.ViewModels.SoundData>,并且列表包含在SoundGroup类中。由于您的数据加载在SoundModel类中,因此我可能只考虑上述实现。

相关内容

  • 没有找到相关文章

最新更新