【问题标题】:How to fix " MaterialDesignFloatingHintTextBox" could not be resolved如何修复“MaterialDesignFloatingHintTextBox”无法解决
【发布时间】:2019-09-29 10:48:41
【问题描述】:

我正在尝试使用 Material Design 制作 UI,但是当我想使用它时出现错误:资源“MaterialDesignFloatingHintTextBox”无法解析。

https://ibb.co/PcvdmqH 错误的样子

我从 NuGet MaterialDesignThemes 安装 我导入了这个xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"

我在 App.xaml 中写了这个:

<ResourceDictionary x:Key="MaterialDesign">
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Blue.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Indigo.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>

我该如何解决?

【问题讨论】:

  • 您需要一个干净的解决方案并在将代码添加到 App.xaml 后重新构建
  • 您找到解决方案了吗?

标签: c# wpf user-interface material-design-in-xaml


【解决方案1】:

你需要把它放在你的 xaml 文件的顶部,你想在其中放置带有样式 materialdesignfloatinghint 样式的文本框

xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"

【讨论】:

    【解决方案2】:

    尝试同时添加以下内容:

    <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBox.xaml" />
    
    

    【讨论】:

      【解决方案3】:

      首先检查您的项目资源,您是否拥有 Material Design 的 nugets。 将此代码添加到您的 App.Xaml 文件中;在 Application.Resources 下。 这个对我有用。 &lt;ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" /&gt;

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-09-09
        • 1970-01-01
        • 2012-04-07
        • 2013-07-05
        • 1970-01-01
        • 1970-01-01
        • 2023-03-16
        • 1970-01-01
        相关资源
        最近更新 更多