对不起,我是C#和WPF的新手。 我尝试使用下载的* .cs文件中的第三方控件: http://www.codeproject.com/Articles/75847/Virtualizing-WrapPanel
描述使用控件的文章:
<ListBox ItemsSource="{StaticResource boundCollection}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingWrapPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
我已将cs文件复制到我的项目文件夹,然后通过拖放到解决方案资源管理器添加它,然后将命名空间更改为我项目的命名空间。但它显示以下错误:
Error 1 The tag 'VirtualizingWrapPanel' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'. Line 30 Position 22. C:\Users\mbp2011\Documents\Visual Studio 2010\Projects\@Experiment\ThumbnailsView\ThumbnailsView\MainWindow.xaml 30 22 ThumbnailsView
提前致谢
答案 0 :(得分:2)
您必须在Xaml中添加引用,它与在cs文件中添加引用(使用)相同
示例:
<Window x:Class="WpfApplication8.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
// Add a reference to the namespace that contains VirtualizingWrapPanel
xmlns:controls="clr-namespace:the namespace of the VirtualizingWrapPanel"
Title="MainWindow" Height="233" Width="405" Name="UI" WindowStyle="ToolWindow">
<ListBox ItemsSource="{StaticResource boundCollection}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
// then use the namespace to access the VirtualizingWrapPanel
<controls:VirtualizingWrapPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</Window>