This is my class file which contains variables which I need to store.
public class general
{
String imagename2;
String name;
public string getimage()
{
return imagename2;
}
public void viewimage(String imagename){
imagename2 = imagename;
}
}
I firstly store it to the class file
selected = lbFiles.SelectedItem.ToString();
general item = new general();
item.viewimage(selected);
MessageBox.Show(selected);
NavigationService.Navigate(new Uri("/View.xaml", UriKind.Relative));
And by the time it redirect to another page, when I retrieve, its null instead of the value
public View()
{
InitializeComponent();
general general = new general();
viewimagename = general.getimage(); // NULL HERE!!!!!!!!!!!!!!!!!!!!!
this.ReadFromIsolatedStorage(viewimagename+".jpg");
// LoadFromLocalStorage();
}
I’ve been thinking and not sure why it became null.
You are creating a new instance of the
generalclass each time, hence you get a new, shiny, blank set of field values.