【问题标题】:Control from WPFToolkit doesn't exist in namespace命名空间中不存在来自 WPFToolkit 的控件
【发布时间】:2026-02-21 21:00:02
【问题描述】:

我添加到引用 WPFToolkit.dll 并添加了我的 .xaml 文件以下行:

xmlns:toolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit"

在下一行之前:

xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"

在这两种情况下都行

<toolkit:NumericUpDown Value="10" Increment="1" Maximum="10" Minimum="0" />

我有错误:

错误 1 ​​XML 命名空间“http://schemas.microsoft.com/wpf/2008/toolkit”中不存在标记“NumericUpDown”。第 20 行位置 18. C:\Users\Diament\Documents\Visual Studio 2008\Projects\MyBasicFlyffKeystroke\MyBasicFlyffKeystroke\Window.xaml 20 18 MyBasicFlyffKeystroke

问题出在哪里? :(

【问题讨论】:

  • 看起来NumericUpDown 已过时。来自:wpftoolkit.codeplex.com/wikipage?title=NumericUpDown。 "[OBSOLETE] - 请使用新的 DecimalUpDown、DoubleUpDown 或 IntegerUpDown 控件之一"
  • 使用 IntegerUpDown 我有同样的错误
  • 你有没有发现这个问题?

标签: c# wpf .net-3.5


【解决方案1】:

我也遇到了同样的问题。

如果我跳过取消阻止步骤并简单地解压缩,xaml 预览窗口将不会加载,并且 VS 会不断给我“IntegerUpDown 组件在命名空间http://schemas.xceed.com/wpf/xaml/toolkit 中不存在”错误,甚至虽然自动完成会很高兴地列出该命名空间中的所有组件。

但是,如果我先取消阻止 zip 文件,然后解压缩,然后在VS 中引用该dll,则一切正常。

TL;DR:遵循installation instructions 完全正确,尤其是首先解除阻止压缩文件。

【讨论】:

    【解决方案2】:

    NumericUpDown 不是basic WPF Toolkit 的一部分,而是Extended WPF Toolkit 的一部分

    使用 IntegerUpDown(或任何 provided derived classes)并确保在您的应用程序中使用适当的 DLL。以下是在您的项目引用扩展 WPF 工具包 DLL (Xceed.Wpf.Toolkit.Dll) 时使用 IntegerUpDown 的示例:

    <Window x:Class="WpfApplication4.Window1"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
            Title="Window1" Height="300" Width="300">
        <Grid>
          <toolkit:IntegerUpDown Value="10" Increment="1" Minimum="0" Maximum="10" />
       </Grid>
    </Window>
    

    【讨论】:

      【解决方案3】:

      试试

      xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
      

      【讨论】:

      • 你有没有重命名这个dll?它应该是 WPFToolkit.Extended.dll
      • 我没有重命名它。我只是写了我自己的控件。谢谢。
      【解决方案4】:

      我遵循了@Andrew 的建议(下载、取消阻止、提取、添加),但仍然遇到同样的问题。

      相反,通过 NUGET 安装(按照他们页面 here 上的说明进行操作)使其无需执行手动步骤即可工作。

      去 nuget ...

      【讨论】:

        【解决方案5】:

        http://wpftoolkit.codeplex.com/documentation

        安装使用说明

        请注意:扩展的 WPF 工具包依赖于 .NET Framework 4.0。您必须安装 .NET Framework 4.0 才能使用 Toolkit 中的任何功能。

        扩展 WPF 工具包二进制文件的使用说明:

        1.Install .NET Framework 4.0. 
        2.Download the ExtendedWPFToolkit_Binaries 
        3.Unblock the ZIP file. 1.Right-click ExtendedWPFToolkit_Binaries.zip -> Properties -> Unblock 
        
        4.Unzip the ExtendedWPFToolkit_Binaries.zip 
        5.Reference the binaries in your project: 
            1.Reference WPFToolkit.Extended.dll in your project (Xceed.Wpf.DataGrid.dll for the datagrid control) 
            2.Add a using statement ("using Xceed.Wpf.Toolkit;" for most of the controls, "using Xceed.Wpf.DataGrid;" for the datagrid control) to the top of .cs files 
            3.Add a new xmlns (xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" for most of the controls, xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid" for the datagrid control) to the top of XAML files 
            4.Remember to use the namespace prefix (in the above example, <xctk: ...> or <xcdg: ...>) in the body of your XAML 
        

        使用 NuGet 安装

        1.Install NuGet (can be downloaded for  this link: https://visualstudiogallery.msdn.microsoft.com/27077b70-9dad-4c64-adcf-c7cf6bc9970c). 
        2.Open your Visual Studio. 
        3.Open your solution/project. 
        4.Open Tools menu, select Library Package Manager and select  Package Manager Console 
        5.Run the following command Install-Package Extended.Wpf.Toolkit 
            1.Add a using statement ("using Xceed.Wpf.Toolkit;" for most of the controls, "using Xceed.Wpf.DataGrid;" for the datagrid control) to the top of .cs files
        
            2.Add a new xmlns (xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" for most of the controls, xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid" for the datagrid control) to the top of XAML files 
            3.Remember to use the namespace prefix (in the above example, <xctk: ...> or <xcdg: ...>) in the body of your XAML 
        

        【讨论】:

        • 我遵循“使用 NuGet 安装”。我所做的只是在控制台中运行命令“Install-Package Extended.Wpf.Toolkit”并修复了“名称“DataGrid”在命名空间“clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit”中不存在"'
        【解决方案6】:

        我发现了同样的错误。您必须卸载当前安装工具包并重新安装工具包才能解决错误。这不是正确的解决方案,但您可以继续工作。

        【讨论】:

        • 为我工作。是否通过项目包管理器安装/卸载。
        【解决方案7】:

        注意:考虑Extended WPF Toolkit - Numeric Up Down,已过时。 他们强烈建议使用任何“专业”版本。顺便说一下,这不应该产生错误,而是警告

        如果找不到程序集,请检查您的项目和Wpf Toolkit 版本的兼容性。

        【讨论】:

        • 我尝试使用 IntegerUpDown 并且我有同样的错误。我有版本 3.5.40128.1,来自页面 wpf.codeplex.com/releases/view/40535(适用于 .NET Framework 3.5)
        • 你项目的版本是什么?
        • 但是我没有sp 1...可以是原因吗?
        • 我也...但我会尝试...所以我们没有更多的想法。