I have multiple view models on Windows Phone 8, this works on Windows Phone 7, but not 8.
In my MainPage.xaml code:
<phone:LongListSelector Name="musicList">
<phone:LongListSelector.GroupHeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Genre}"/>
</DataTemplate>
</phone:LongListSelector.GroupHeaderTemplate>
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Artist}"/>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
<phone:LongListSelector.ListFooterTemplate>
<DataTemplate>
<TextBlock Text="{Binding Song}"/>
</DataTemplate>
</phone:LongListSelector.ListFooterTemplate>
</phone:LongListSelector>
In my MainPage.xaml.cs code:
musicList.ItemsSource = App.Music;
In my App.xaml.cs code:
using MyMusic.Assets.ViewModels.Music;
private static MusicList m_Music = new MusicList();
public static MusicList Music
{
get { return m_Music; }
}
In my /Assets/ViewModels/Music/MusicList.cs
public class MusicList : ObservableCollection<Genre>
{
public MusicList()
{
this.Clear();
}
}
In my /Assets/ViewModels/Music/Genre.cs
public class Genre : ObservableCollection<Artist>
{
public Genre()
{
this.Clear();
}
public string Genre { get; set; }
}
In my /Assets/ViewModels/Music/Artist.cs
public class Artist : ObservableCollection<SongItem>
{
public Artist()
{
this.Clear();
}
public string Artist { get; set; }
}
In my /Assets/ViewModels/Music/SongItem.cs
public class SongItem : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public string Song { get; set; }
protected void NotifyPropertyChanged(string thePropertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(thePropertyName));
}
}
}
This code in the MainPage.xaml code reaches "Genre" and then it doesn't get any of the other fields after that on Windows Phone 8, however, on Windows Phone 7, it would keep going through all the modules.
How do I get this to get all the module fields that have been added?
It keeps reporting an error when debugging:
System.Windows.Data Error: BindingExpression path error: 'Artist' property not found on 'Assets.ViewModels.MusicList.Genre' 'Assets.ViewModels.Music.Genre' (HashCode=21418771). BindingExpression: Path='Artist' DataItem='Assets.ViewModels.Music.Genre' (HashCode=21418771); target element is 'System.Windows.Controls.TextBlock' (Name=''); target property is 'Text' (type 'System.String')..
I have this linked with ObservableCollection<>
and it's not linking it to get the "Artist" string as the error states. What would be causing this? How do I change the path to Music.Genre.Artist, so that it will work?