微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Xaml 属性具有多个静态类的常量

如何解决Xaml 属性具有多个静态类的常量

我从项目中的图像文件生成了一些常量。但是,我无法将多个静态类作为 Xaml 属性访问。

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}"

我已经尝试了几种变体,但是我只能指定 {x:Static common:Constants.Svg}

我发现

enter image description here

作为初始基础,但它不使用多个类。

我很乐意更改常量类的格式。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。