简体   繁体   English

WPF MahApps.Metro 资源未找到

[英]WPF MahApps.Metro Resources not found

I updated the Packages recently and since then my recourses are not found anymore.我最近更新了包,从那以后我的资源就再也找不到了。 Only the Controls and the Fonts are found but not the rest which i find really confusing.只找到了控件和 Fonts,但没有找到 rest,我觉得这很令人困惑。 Did anyone had a similar problem?有没有人遇到过类似的问题? BR Max最大BR

<Application x:Class="Tools.Shell.App"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:local="clr-namespace:Tools.Shell">
        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
                    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
                    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
                    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
                    <!-- Accent and AppTheme setting -->
                    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Teal.xaml" />
                    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
                    <!-- Button Theme setting -->
                    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml" />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Application.Resources>
    </Application>

错误

This is a case of.这是一个案例。 when you upgrade a package, always check the documents for breaking changes当您升级 package 时,请务必检查文档是否有重大更改

Migration to v2.0迁移到 v2.0

Theming主题化

The theming got rewritten, this means that there is no longer a separation between AppTheme and Accent.主题被重写,这意味着 AppTheme 和 Accent 之间不再有分离。 These got replaced by Theme everywhere.这些到处都被主题所取代。 Instead of something like pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml and pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml you now have to use pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml.而不是像 pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml 和 pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight 之类的东西。 xaml 您现在必须使用 pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml。

Old老的

<Application x:Class="WpfApplication.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
  <Application.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Application.Resources>
</Application>

New新的

<Application x:Class="WpfApplication.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
  <Application.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Application.Resources>
</Application>

Note : I don't use this package (or any of his stuff), there may be more to this story, however at least it might point you in the right direction.注意:我不使用这个 package(或他的任何东西),这个故事可能还有更多,但至少它可能会为你指明正确的方向。 You need to read the rest of the documentation about migration您需要阅读有关迁移的文档的 rest

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM