Share via


VisualElement.Resources 属性

定义

获取或设置本地资源字典。

public:
 property Microsoft::Maui::Controls::ResourceDictionary ^ Resources { Microsoft::Maui::Controls::ResourceDictionary ^ get(); void set(Microsoft::Maui::Controls::ResourceDictionary ^ value); };
public Microsoft.Maui.Controls.ResourceDictionary Resources { get; set; }
member this.Resources : Microsoft.Maui.Controls.ResourceDictionary with get, set
Public Property Resources As ResourceDictionary

属性值

当前资源字典,其中资源按键存储。

注解

在 XAML 中,资源字典填充在 XAML 中指定的键/值对,因此在运行时创建。 资源字典中的键是使用 x:Key 要创建的类型的 XAML 标记的 属性指定的。 将创建该类型的对象,并使用附加属性或嵌套标记指定的属性和字段值进行初始化,这两个值(如果存在)只是属性或字段名称的字符串表示形式。 然后,在运行时将 对象插入 ResourceDictionary 到封闭类型的 中。

资源字典及其关联的 XML 为应用程序开发人员提供了一种方便的方法,用于在 XAML 编译时引擎和运行时引擎内重复使用代码。

有关详细信息,请参阅: 资源字典 (Microsoft Learn)

适用于