Constants with multiple static class for Xaml properties

I've generated some constants from images files in our project. However, I'm having trouble accessing multiple static classes as a Xaml property.

Cannot resolve type "Constants.Images.Icons.IcAccount.Svg". (XFC0000)

namespace Common
{
    public static class Constants
    {
        public static class Images
        {
            public static class Icons
            {
                public static class IcAccount
                {
                    public static readonly string Svg = "res:images.icons.ic_account";
                    public static readonly string File = "ic_account.svg";
                }
<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage
  x:Class="myapp.Pages.ActiveBookingPage"
  xmlns="http://xamarin.com/schemas/2014/forms"
  xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
  xmlns:control="clr-namespace:myapp.Controls;assembly=myapp"
  xmlns:common="clr-namespace:myapp.Common;assembly=myapp">

    <ContentPage.Content>
        <control:CustomImageButton
            ButtonImage="{x:Static common:Constants.Images.Icons.IcAccount.Svg}"

I've tried several variations however I can't specify any more than {x:Static common:Constants.Svg}

I found this as an initial basis, but it doesn't use multiple classes.

I’d be happy to change the format of my constants class.



Read more here: https://stackoverflow.com/questions/65701356/constants-with-multiple-static-class-for-xaml-properties

Content Attribution

This content was originally published by Jules at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: