0

I have been looking at this: http://code.msdn.microsoft.com/wpapps/Custom-LongList-Selector-bf8cb9ad and trying to incorporate into my app. However, its a little confusing since my data is loaded differently. Right now, I have two errors The best overloaded method match for CustomKeyGroup<.ViewModels.SoundData>.GetSoundGroups(System.Collections.Generic.List<.ViewModels.SoundData>)' has some invalid arguments

Argument 1: cannot convert from 'string' to 'System.Collections.Generic.List'

The error is at 'CustomKeyGroup.GetSoundGroups(mvm.Items);' from the mainpage.cs. I know the items is an issue. If you look at the link, they load the data differently w/ listmovie.add.

I know something is screwed up big time but since my data is loaded different, im struggling to get it working correctly.

Id like to have custom jumplist w/ headers by Groups (Alpha, Bravo, etc) located in my SoundModel. Here is a portion:

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"
            });

Here is the relevant 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);
        }

    }
}
4

1 回答 1

0

So far from I what can see you should be calling the function as below

SoundModel svm = new SoundModel();
svm.LoadData();

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

or

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

the reason is that you need to pass a Generic.List<.ViewModels.SoundData> in method GetSoundGroups and the list is contained in SoundGroup class. Since your data loaded is within SoundModel class so I could probably think of the above implementation only.

于 2014-06-21T07:57:02.023 回答