Whats the best way to handle global variables?

SmeSme USMember ✭✭✭

In android you have the strings and styles files, but is there a good way to handle this in Xamarin.Forms? I'd prefer to have the code in the Portable project.

Should I just create a class called Global.cs, and have it contain a bunch of static methods (for example, a static method to get the string for the name of the app, a static method to get the string for the Hex color for the app's "brand" color, etc.)?

Thanks

Posts

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    app.cs is already global-scope and in the PCL. It is your app, after all.

  • NMackayNMackay GBInsider, University mod

    I usually have a settings class that I register in the IoC and inject into viewmodels and can be accessed in the platform specific projects via the dependency service.

Sign In or Register to comment.