Often, 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
** Note ** Jesse is currently looking for a new position. You can learn more about him at https://jesseliberty.bio Thank you.
Jesse Liberty has three decades of experience writing and delivering software projects and is the author of 2 dozen books and a couple dozen online courses. His latest book, Building APIs with .NET, is now available wherever you buy your books.
Liberty was a Team Lead and Senior Software Engineer for various corporations, 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 13 year Microsoft MVP.