ResourceLoader 類別

定義

提供應用程式資源的簡化存取,例如應用程式 UI 字串。

public ref class ResourceLoader sealed
/// [Windows.Foundation.Metadata.Activatable(65536, "Microsoft.Windows.ApplicationModel.Resources.MrtContract")]
/// [Windows.Foundation.Metadata.Activatable(Microsoft.Windows.ApplicationModel.Resources.IResourceLoaderFactory, 65536, "Microsoft.Windows.ApplicationModel.Resources.MrtContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Windows.ApplicationModel.Resources.MrtContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class ResourceLoader final
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Microsoft.Windows.ApplicationModel.Resources.MrtCoreContract")]
/// [Windows.Foundation.Metadata.Activatable(Microsoft.Windows.ApplicationModel.Resources.IResourceLoaderFactory, 65536, "Microsoft.Windows.ApplicationModel.Resources.MrtCoreContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Windows.ApplicationModel.Resources.MrtCoreContract, 65536)]
class ResourceLoader final
[Windows.Foundation.Metadata.Activatable(65536, "Microsoft.Windows.ApplicationModel.Resources.MrtContract")]
[Windows.Foundation.Metadata.Activatable(typeof(Microsoft.Windows.ApplicationModel.Resources.IResourceLoaderFactory), 65536, "Microsoft.Windows.ApplicationModel.Resources.MrtContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Windows.ApplicationModel.Resources.MrtContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class ResourceLoader
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(65536, "Microsoft.Windows.ApplicationModel.Resources.MrtCoreContract")]
[Windows.Foundation.Metadata.Activatable(typeof(Microsoft.Windows.ApplicationModel.Resources.IResourceLoaderFactory), 65536, "Microsoft.Windows.ApplicationModel.Resources.MrtCoreContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Windows.ApplicationModel.Resources.MrtCoreContract), 65536)]
public sealed class ResourceLoader
function ResourceLoader(fileName, resourceMap)
Public NotInheritable Class ResourceLoader
繼承
Object Platform::Object IInspectable ResourceLoader
屬性

備註

ResourceLoader物件會封裝特定的ResourceMapResourceCoNtext,並結合在簡單的 API 中。

取得 ResourceLoader 時,可以指定特定的資源對應;如果未指定資源對應, ResourceLoader 會提供應用程式主要資源對應之「資源」子樹的存取權。

一般而言,資源可能會區分縮放或其他顯示特性。 因此,資源內容通常會與特定檢視相關聯。 由於 ResourceLoader 會封裝資源內容,因此這也適用于 ResourceLoader

  • 使用 DisplayInformation 類別來取得目前檢視的縮放比例,而不是已被取代的 DisplayProperties 類別。
  • 設定元素明確寬度和高度的應用程式應該仍然正常運作,但可能顯示模糊影像以外的應用程式。

另請參閱 螢幕大小和中斷點

建構函式

ResourceLoader()

為目前執行中應用程式主要ResourceMap的 「Resources」 子樹建構新的ResourceLoader物件。

ResourceLoader(String)

為指定的ResourceMap建構新的ResourceLoader物件。

ResourceLoader(String, String)

為指定的內容和對應建立 ResourceLoader

方法

GetDefaultResourceFilePath()

取得預設的資源檔路徑,這是如果未指定任何自訂路徑,則會使用 建立 ResourceLoader 的路徑。

GetString(String)

傳回資源識別碼所指定的資源最適當的字串值。

GetStringForUri(Uri)

針對目前執行中應用程式的預設 ResourceCoNtext ,傳回由統一資源識別項所指定的最適當的資源值 (URI) 資源識別碼。

適用於