Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i am making wpf app which have two page.first page add items in list(ObservableCollection) and second page display this list using listview control .i am using frame in window(wpf) to display page.list correctly work in page1 but when page navigate (page1 to page2) list lost its data and doesn't show anything in listview in page2.
so what should i do?please help.
This is class with name "variableholder" which keep list and data.
C#
class Variableholder
    {
        private ObservableCollection<MusicTags> Tagslist = new ObservableCollection<MusicTags>();
        public ObservableCollection<MusicTags> list(){
            return Tagslist;
        }
    }
    class MusicTags
    {
        public string Title { get; set; }
        public string Album { get; set; }
        public string Artist { get; set; }
        public string Albumartist { get; set; }
        public string Genre { get; set; }
        public string Composers { get; set; }
        public string Name { get; set; }
        }
Posted
Updated 5-Feb-15 2:58am
v2
Comments
User-8621695 10-Feb-15 5:52am    
Pass that collection to the second page when moving to second page.
Or make class as static to that you can get the vaue to the second page.
Ganesh KP 12-Feb-15 4:38am    
I guess that you might be creating a new instance of the VariableHolder when you are actually moving to second page. In that case you will all new values. To achieve the functionality of what you asked, is, either create a static class of Variable Holder or else, pass the data from one page to another by using a public property or else a parameter to the control (page2).

1 solution

Module 1:
C#
ObservationCollection<variableholder> lstVariable = new ObservationCollection<variableholder>();
</variableholder></variableholder>


Module 2:
C#
public ObservableCollection<variableholder> variableData
    {
        get { return _varialbleholder ; }
        set {_varialbleholder = value; }
    }
</variableholder>



assign values to your lstvarialble in Module 1, when you want to pass it to Module 2 :
C#
Moduel2.variableData = lstvariable;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900