[英]Visual studio like search
I want to implement Visual Studio like search. 我想像搜索一样实现Visual Studio。 For now I want to make it search my UserControls
, and on click it should open them in Tab
. 现在我想让它搜索我的UserControls
,点击它应该在Tab
打开它们。 I'm not searching for code, just for the right guidelines and the right terminology to try to implement this. 我不是在寻找代码,只是为了正确的指导方针和正确的术语来尝试实现这一点。 Thanks for any advice. 谢谢你的建议。
Example: 例:
For searching in your UserControl
collection I would use LINQ
. 要在UserControl
集合中搜索,我会使用LINQ
。
List<UserControl> results = (from UserControl control in list_of_usercontrols where (control.SomeParameter.ToLower().Contains(SearchParameter) || control.OtherParameter.ToLower().Contains(SearchParameter)) && nnn.IsEnabled select nnn).Distinct().ToList();
For displaying results I highly recommend ListView
. 为了显示结果,我强烈推荐ListView
。 I use it to show results in my WPF app, it's incredibly fast. 我用它在我的WPF应用程序中显示结果,它非常快。
listView1.ItemsSource = results;
You can set ItemTemplate
for your ListView
. 您可以为ListView
设置ItemTemplate
。
<ListView Grid.Row="1" Name="listView1" BorderThickness="0" SelectionMode="Single" >
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label FontSize="15" >
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding SomeProperty}"></TextBlock>
<TextBlock Text="{Binding OtherProperty}"></TextBlock>
<TextBlock Text="{Binding ThirdProperty}" ></TextBlock>
</StackPanel>
</Label>
<Label Content="{Binding FourthProperty}" Grid.Row="1" Padding="5,0,0,5"></Label>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.