1
我想實現像搜索一樣的Visual Studio。現在我想讓它搜索我的UserControls
,點擊它應該打開它們在Tab
。 我不是在尋找代碼,只是爲了正確的指導方針和正確的術語來嘗試實現這一點。 感謝您的任何建議。視覺工作室喜歡搜索
例子:
我想實現像搜索一樣的Visual Studio。現在我想讓它搜索我的UserControls
,點擊它應該打開它們在Tab
。 我不是在尋找代碼,只是爲了正確的指導方針和正確的術語來嘗試實現這一點。 感謝您的任何建議。視覺工作室喜歡搜索
例子:
對於您的收藏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();
爲了顯示結果我強烈推薦ListView
。我用它在我的WPF應用程序中顯示結果,它的速度非常快。
listView1.ItemsSource = results;
您可以爲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>