我有一个listview,绑定了一个可观察的对象集合。这里的对象是“问题”。我想实现一种搜索引擎。在文本框或什么的。但我有3列。 1的描述,1的简称和1的问题类型。这里是我的列表视图的代码:用wpf在列表框中搜索
<ListView IsTextSearchEnabled="True" TextSearch.TextPath="Description" ScrollViewer.CanContentScroll="True" SelectedItem="{Binding Path=SelectedQuestionDragList, UpdateSourceTrigger=PropertyChanged,Mode=OneWayToSource}" dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="False" Margin="0,34,393,333" Background="#CDC5CBC5" ScrollViewer.VerticalScrollBarVisibility="Visible"
dd:DragDrop.DropHandler="{Binding}" Name="listbox1" Height="155" ItemsSource="{Binding AvailableQuestions}" SelectionChanged="listbox1_SelectionChanged">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="Verkorte naam" Width="Auto" DisplayMemberBinding="{Binding Path=ShortName}" />
<GridViewColumn Header="Omschrijving" Width="Auto" DisplayMemberBinding="{Binding Path=Description}" />
<GridViewColumn Header="Type" Width="Auto" DisplayMemberBinding="{Binding Path=Type}" />
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
我已经尝试了很多东西。但我只想保留一件简单的事情:一个文本框,如果你填写了一些字母,程序必须过滤这个字母组合存在的位置。有人知道一个简单的解决方案或例子?
谢谢!
,但是这一切都是在后面的代码我猜想?我试图保持我的代码清洁,并与MVVM一起工作。有关如何做到这一点的想法? – Ruben 2011-04-11 13:05:24
@Ruben,查看我的答案,了解如何在虚拟机中执行此操作。 – Robaticus 2011-04-11 13:16:32
无论哪种方式工作..这里的关键是'CollectionViewSource',通过创建它或使用默认值。 – Arcturus 2011-04-11 13:33:56