1

我目前正在使用 T10 开发一个简单的应用程序,使用空白模板。然后,我从 Hamburger 模板中看到您通过像这样添加Application.Resource将Custom.xaml 主题应用到 App.xamlApp.xaml

<common:BootStrapper x:Class="T10Hamburger.App" 
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                     xmlns:common="using:Template10.Common">

    <Application.Resources>
        <ResourceDictionary Source="Styles\Custom.xaml" />
    </Application.Resources>

</common:BootStrapper>

我在我的项目中做了同样的事情,但我得到了 XAML 异常。

这是来自异常的消息:

“对 COM 组件的调用已返回错误 HRESULT E_FAIL。”

我错过了什么?

nb:注意一点,当我尝试手动输入 Application.Resource App.xaml 时,Intellisense 没有捕捉到该 Application 部分,但后来显示当我尝试完成它时Resource

4

2 回答 2

2

对我来说,你的问题在这里:

<Application.Resources>它应该是 <common:BootStrapper.Resources>

换句话说,您应该拥有:

<common:BootStrapper x:Class="T10Hamburger.App" 
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                     xmlns:common="using:Template10.Common">

    <common:BootStrapper.Resources>
        <ResourceDictionary Source="Styles\Custom.xaml" />
    </common:BootStrapper.Resources>

</common:BootStrapper>
于 2016-03-04T23:15:00.237 回答
0

重新启动 Visual Studio 是我的解决方案。

于 2016-07-08T15:00:20.773 回答