簡體   English   中英

具有多個 static class 的常量,用於 Xaml 屬性

[英]Constants with multiple static class for Xaml properties

我已經從我們項目中的圖像文件中生成了一些常量。 但是,我無法將多個 static 類作為 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}

我發現是一個初步的基礎,但它不使用多個類。

我很樂意更改常量 class 的格式。

編譯器做了一些聰明的事情來管理嵌套類,用“+”用完整的類樹重命名它。

利用

common:Constants+Images+Icons+IcAccount.Svg

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM