共用方式為


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)

適用於