Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将应用程序资源添加到应用程序的C#后端而不是XAML文件中?_C#_Xamarin_Xamarin.forms - Fatal编程技术网

如何将应用程序资源添加到应用程序的C#后端而不是XAML文件中?

如何将应用程序资源添加到应用程序的C#后端而不是XAML文件中?,c#,xamarin,xamarin.forms,C#,Xamarin,Xamarin.forms,在我的XAML文件中,我有以下内容: <Application x:Class="App" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:converters="clr-namespace:M"> &

在我的XAML文件中,我有以下内容:

<Application
    x:Class="App"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:converters="clr-namespace:M">
    <Application.Resources>
        <converters:InverseBool x:Key="InverseBool" />
        <Color x:Key="IconAsphalt">#34495E</Color>
    </Application.Resources>
</Application>
例如,我不知道如何为
inverseebool
指定名称空间

希望有人能帮我做这件事。

您只需使用

当然,您需要包括定义
InverseBool
类的名称空间。

您只需使用


当然,您需要包括定义
InverseBool
类的名称空间。

名称空间不应该那么难,就像使用
Yes在关键字
之后的.cs文件顶部的名称空间一样,但是我如何添加它,因为有一个字符串作为第一个参数?名称空间不应该那么难,这与使用
Yes在.cs文件顶部紧跟关键字
之后的名称空间相同,但由于第一个参数是字符串,如何添加该名称空间?
public App()
{
    Resources.Add("InverseBool", "InverseBool");
Resources.Add("InverseBool", new InverseBool());