ResourceLoader.GetForCurrentView 方法

定义

重载

GetForCurrentView()

获取当前正在运行的应用main ResourceMap 的资源子树ResourceLoader 对象。 ResourceLoader 使用与当前视图关联的默认上下文。

GetForCurrentView(String)

获取指定 ResourceMap 的 ResourceLoader 对象。 此 ResourceLoader 使用与当前视图关联的默认上下文。

GetForCurrentView()

获取当前正在运行的应用main ResourceMap 的资源子树ResourceLoader 对象。 ResourceLoader 使用与当前视图关联的默认上下文。

public:
 static ResourceLoader ^ GetForCurrentView();
/// [Windows.Foundation.Metadata.Overload("GetForCurrentView")]
 static ResourceLoader GetForCurrentView();
[Windows.Foundation.Metadata.Overload("GetForCurrentView")]
public static ResourceLoader GetForCurrentView();
function getForCurrentView()
Public Shared Function GetForCurrentView () As ResourceLoader

返回

当前正在运行的应用main ResourceMap 的资源子树的资源加载程序。

属性

示例

请参阅 ResourceLoader 中的示例。

注解

此方法允许访问名为“resources”的资源文件, (resources.resjson 或 resources.resw) 。 返回的 ResourceLoader 使用与当前视图关联的默认上下文。

UWP 应用的资源管理系统支持为缩放定制资源。 从Windows 8.1开始,应用拥有的不同视图能够在可能使用不同的比例的不同显示设备上同时显示。 这样,缩放是按视图的特征。

ResourceLoader 具有隐式上下文,当 ResourceLoader 方法用于检索资源时,该上下文将使用该上下文。 由于 ResourceLoader 具有隐式上下文,并且由于上下文的规模限定符依赖于关联的视图, 因此 ResourceLoader 必须与特定视图相关联。

错误

如果在无窗口线程中调用此方法,或者如果 main ResourceMap 没有“resources”子树,则此方法将失败并引发异常。

另请参阅

适用于

GetForCurrentView(String)

获取指定 ResourceMap 的 ResourceLoader 对象。 此 ResourceLoader 使用与当前视图关联的默认上下文。

public:
 static ResourceLoader ^ GetForCurrentView(Platform::String ^ name);
/// [Windows.Foundation.Metadata.Overload("GetForCurrentViewWithName")]
 static ResourceLoader GetForCurrentView(winrt::hstring const& name);
[Windows.Foundation.Metadata.Overload("GetForCurrentViewWithName")]
public static ResourceLoader GetForCurrentView(string name);
function getForCurrentView(name)
Public Shared Function GetForCurrentView (name As String) As ResourceLoader

参数

name
String

Platform::String

winrt::hstring

新资源加载程序用于非限定资源引用的 ResourceMap 的资源标识符。 然后,加载程序可以检索与这些引用相关的资源。

注意

资源标识符被视为统一资源标识符 (URI) 片段,受统一资源标识符 (URI) 语义的约束。 例如,“Caption%20”被视为“Caption”。 请勿在资源标识符中使用“?”或“#”,因为它们会终止命名资源路径。 例如,“Foo?3”被视为“Foo”。

返回

指定 ResourceMap 的资源加载程序。

属性

示例

请参阅 ResourceLoader 中的示例。

注解

此方法通常用于访问相对于具有指定资源标识符的资源文件的资源。 例如, GetForCurrentView('Errors'); 相对于 errors.resjson 或 errors.resw。

若要为库包中的资源构造资源加载程序,请使用资源引用统一资源标识符 (URI) 。

返回的 ResourceLoader 使用与当前视图关联的默认上下文。

UWP 应用的资源管理系统支持为缩放定制资源。 从Windows 8.1开始,应用拥有的不同视图能够在可能使用不同的比例的不同显示设备上同时显示。 这样,缩放是按视图的特征。

ResourceLoader 具有隐式上下文,当 ResourceLoader 方法用于检索资源时,该上下文将使用该上下文。 由于 ResourceLoader 具有隐式上下文,并且由于上下文的规模限定符依赖于关联的视图, 因此 ResourceLoader 必须与特定视图相关联。

错误

如果在无窗口线程中调用此方法,或者找不到指定的 ResourceMap ,则此方法失败并出现异常。

另请参阅

适用于