Xamarin.Forms And Resources

ResourcesOften, there will be multiple views in your form that share the same values (e.g., font size, color, etc.).  There are a couple ways you can handle this:

  • Create a resource dictionary and then refer to the resources using the key and the keyword StaticResource
  • Declare constants and then refer to them using x:Static

While the names are very similar, x:Static and Static resources work differently.  The former access a public static constant  (or a public static property defined by a class).  The latter, static resources, is a markup extension supported by xAML that depends on the creation of a resource dictionary.

Let’s look at how you might use both.  More…

About Jesse Liberty

Jesse Liberty is a Senior Consultant with Wintellect, with three decades of experience writing and delivering software projects. He is the author of 2 dozen books and multiple Pluralsight & LinkedIn Learning courses, and has been a Senior Technical Evangelist for Microsoft, a Distinguished Software Engineer for AT&T, a VP for Information Services for Citibank and a Software Architect for PBS. He is a Xamarin Certified Mobile Developer and a Xamarin MVP and a Microsoft MVP.
This entry was posted in Essentials. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *