共用方式為


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 資源參考失敗的英文) 中,人類可讀的描述 (。

範例

以下是在不正確的資源參考 (OutputTextBlockStyl 而不是 OutputTextBlockStyle 刻意插入) 之後,來自 WinUI 資源庫範例應用程式的範例訊息。 如果您知道所需的資源定義在 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 已搜尋,這可能表示指定了不正確的資源索引鍵。

適用於

另請參閱