Share via

UWP, C#, Application Cache for Storing Application Settings and other variables.

VoyTec 671 Reputation points
2021-04-21T18:07:14.613+00:00

Greetings VS Community,

I ask for help for UWP, C#, Application Cache for Storing Application Settings and other variables.
I went through a lot of documentations about it and what I figured out on my own is missing Namespace called Windows.Storage.AccessCache that nobody mentioned. This one, simple code help to compilate without errors half of my code, but declaring variable to Cache gives me troubles using compilator.
Can somebody explain me how to store values between pages step by step with all libraries (ex. Windows.Storage.AccessCache and so on). Simple application to present one value to two pages but not with String Query, I want more variables to be stored.

Thanks a bunch for any help.

Developer technologies | Universal Windows Platform (UWP)
0 comments No comments

Answer accepted by question author

AryaDing-MSFT 2,916 Reputation points
2021-04-22T07:18:55.247+00:00

Hi,

Welcome to Microsoft Q&A!

To store values between pages, it is recommended to achieve a static Dictionary in App class. As follows:

App.xaml.cs:

 sealed partial class App : Application  
   {  
       public static Dictionary<int, string> Dic;  
        public App()  
        {  
            this.InitializeComponent();  
            Dic = new Dictionary<int, string>  
            {  
                {1,"Tom" },  
                {2,"Jack"},  
                {3,"Lily"}  
            };  
            this.Suspending += OnSuspending;  
        }  
………  
}  

If you want access the value, you only need to call App.Dic[key], such as App.Dic1, which value is “Tom”.


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.