WPFToolkit中的Control在命名空间中不存在。

16

我已添加了引用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:标签“NumericUpDown”在XML命名空间“http://schemas.microsoft.com/wpf/2008/toolkit”中不存在。第20行,第18个位置。C:\Users\Diament\Documents\Visual Studio 2008\Projects\MyBasicFlyffKeystroke\MyBasicFlyffKeystroke\Window.xaml 20 18 MyBasicFlyffKeystroke

问题出在哪里? :(


它看起来像是NumericUpDown已经过时了。来自:http://wpftoolkit.codeplex.com/wikipage?title=NumericUpDown。 “[已过时] - 请使用新的DecimalUpDown、DoubleUpDown或IntegerUpDown控件之一”。 - Fredrik Hedblad
1
使用IntegerUpDown时,我遇到了相同的错误。 - cadi2108
你最终解决了这个问题吗? - JLott
7个回答

9

我有完全相同的问题。

如果我跳过解除锁定步骤,仅仅解压缩,XAML 预览窗口将无法加载,VS 将继续给出“IntegerUpDown 组件不存在于命名空间 http://schemas.xceed.com/wpf/xaml/toolkit”错误,尽管自动完成会愉快地列出该命名空间中的所有组件。

然而,如果我首先解除锁定 ZIP 文件,然后提取,然后在 VS 中引用 DLL,则一切都正常工作。

简短概括:严格遵循安装说明,特别是首先解除锁定 ZIP 文件。


5

NumericUpDown不是基本WPF工具包的一部分,而是扩展WPF工具包的一部分。

使用IntegerUpDown(或任何提供的派生类),并确保在您的应用程序中使用适当的DLL。下面是一个示例,当您的项目引用了扩展WPF Toolkit 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>

2

http://wpftoolkit.codeplex.com/documentation

安装和使用说明

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

使用扩展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 

1
我按照“使用NuGet进行安装”的步骤操作。我只是在控制台中运行了命令“Install-Package Extended.Wpf.Toolkit”,它就解决了“名称“DataGrid”在命名空间“clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit”中不存在”的问题。 - icernos

2

我按照@Andrew的建议进行了下载、解压、添加等操作,但仍然遇到了相同的问题。

相反,通过NUGET安装(请按照他们网页上这里的说明)可以使其工作,而无需执行手动步骤。

走起,使用nuget吧...


2

我发现了同样的错误。你需要卸载当前安装的工具包并重新安装工具包,这将解决错误。虽然这不是一个完美的解决方案,但你可以继续你的工作。


1
对我有用。通过项目的软件包管理器进行了安装/卸载。 - geometrikal

2

尝试

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

你有没有重命名这个dll文件?它应该是WPFToolkit.Extended.dll。 - cppanda
我没有重命名它。我只是编写了自己的控件。谢谢。 - cadi2108

0
注意:考虑到扩展WPF工具包-数字上下文已经过时。 他们强烈建议使用任何“专业”版本。这,顺便说一下,不应该生成错误,但是会有警告
如果找不到程序集怎么办,请检查您的项目和Wpf Toolkit版本的兼容性。

1
我尝试使用IntegerUpDown,但是出现了相同的错误。我使用的版本是3.5.40128.1,来自http://wpf.codeplex.com/releases/view/40535页面(适用于.NET Framework 3.5)。 - cadi2108
你的项目版本是什么? - Tigran
但我还没有定义变量sp1... 这可能是原因吗? - cadi2108
我也……但是我会尝试……所以我们没有更多的想法。 - cadi2108

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接