XamlResourceReferenceFailedEventArgs.Message 属性

定义

获取 XAML 资源引用失败) 英语 (用户可读的说明。

public:
 property Platform::String ^ Message { Platform::String ^ get(); };
winrt::hstring Message();
public string Message { get; }
var string = xamlResourceReferenceFailedEventArgs.message;
Public ReadOnly Property Message As String

属性值

String

Platform::String

winrt::hstring

XAML 资源引用失败) 以英语 (用户可读的说明。

示例

下面是一个来自 WinUI 库示例应用的示例消息,该应用在故意插入了错误的资源引用 (OutputTextBlockStyl 而不是 OutputTextBlockStyle) 。 如果知道所需的资源是在 中 App.xaml定义的,则未能在 中查找该资源,则表明存在错误引用。

注意

此示例输出仅用于说明目的。 消息的精确格式是实现定义的,将来可能会更改。 应用程序不应尝试分析消息。

Beginning search for resource with key 'OutputTextBlockStyl'.
  Searching dictionary 'ms-appx:///Controls/ControlExample.xaml' for resource with key 'OutputTextBlockStyl'.
  Finished searching dictionary 'ms-appx:///Controls/ControlExample.xaml'.
  Searching dictionary 'Framework-defined colors' for resource with key 'OutputTextBlockStyl'.
  Finished searching dictionary 'Framework-defined colors'.
  Searching dictionary 'Framework ThemeResources.xbf' for resource with key 'OutputTextBlockStyl'.
    Searching theme dictionary (active theme: 'Light') for resource with key 'OutputTextBlockStyl'.
      Searching dictionary '<anonymous dictionary>' for resource with key 'OutputTextBlockStyl'.
      Finished searching dictionary '<anonymous dictionary>'.
    Finished searching theme dictionary (active theme: 'Light').
  Finished searching dictionary 'Framework ThemeResources.xbf'.
  Searching dictionary 'ms-appx:///App.xaml' for resource with key 'OutputTextBlockStyl'.
    Searching merged dictionary with index '1' for resource with key 'OutputTextBlockStyl'.
      Searching dictionary 'ms-appx:///Microsoft.UI.Xaml/Themes/themeresources.xaml' for resource with key 'OutputTextBlockStyl'.
        Searching theme dictionary (active theme: 'Light') for resource with key 'OutputTextBlockStyl'.
          Searching dictionary 'ms-appx:///Microsoft.UI.Xaml/Themes/themeresources.xaml' for resource with key 'OutputTextBlockStyl'.
          Finished searching dictionary 'ms-appx:///Microsoft.UI.Xaml/Themes/themeresources.xaml'.
        Finished searching theme dictionary (active theme: 'Light').
      Finished searching dictionary 'ms-appx:///Microsoft.UI.Xaml/Themes/themeresources.xaml'.
    Finished searching merged dictionary with index '1'.
    Searching merged dictionary with index '0' for resource with key 'OutputTextBlockStyl'.
      Searching dictionary 'ms-appx:///ItemTemplates.xaml' for resource with key 'OutputTextBlockStyl'.
      Finished searching dictionary 'ms-appx:///ItemTemplates.xaml'.
    Finished searching merged dictionary with index '0'.
    Searching theme dictionary (active theme: 'Light') for resource with key 'OutputTextBlockStyl'.
      Searching dictionary 'ms-appx:///App.xaml' for resource with key 'OutputTextBlockStyl'.
      Finished searching dictionary 'ms-appx:///App.xaml'.
    Finished searching theme dictionary (active theme: 'Light').
  Finished searching dictionary 'ms-appx:///App.xaml'.
Finished search for resource with key 'OutputTextBlockStyl'.

注解

事件数据中的消息包含有关失败的 XAML 资源引用的以下信息:

  • XAML 页的 URI,其中包含搜索的每个 ResourceDictionary
  • ResourceDictionary搜索 的顺序。

可以使用此信息来调查无法解析 XAML 资源引用的原因。 例如,可能 ResourceDictionary 包含资源的 不在已搜索的 ResourceDictionary列表中;也可能 ResourceDictionary 是搜索的,这可能指示指定了不正确的资源键。

适用于

另请参阅