title: C# display specific item in listview
body: <p>I'm doing an assignment involve searching in a listview. I have a textbox and a listview that bind to a list&lt;>. And I want to display the item in the listview which is similar to what I type in the textbox, or at least scroll to it. Here is my code:
  XAML code:</p>
  
  <pre><code>&lt;Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="using:MathDictionary"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:ViewModel="using:MathDictionary.ViewModel"
  x:Class="MathDictionary.MainPage"
  mc:Ignorable="d"&gt;
  
  &lt;Page.DataContext&gt;
      &lt;ViewModel:MainViewModel/&gt;
  &lt;/Page.DataContext&gt;
  
  &lt;Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"&gt;
      &lt;Grid&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="200"&gt;&lt;/ColumnDefinition&gt;
              &lt;ColumnDefinition Width="auto"&gt;&lt;/ColumnDefinition&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="150"&gt;&lt;/RowDefinition&gt;
              &lt;RowDefinition Height="auto"&gt;&lt;/RowDefinition&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;StackPanel Width="200" HorizontalAlignment="Left" Grid.Row="1"&gt;
              &lt;TextBox x:Name="SearchT" TextChanged="SearchT_TextChanged_1"&gt;&lt;/TextBox&gt;
              &lt;ListView x:Name="ListWord" ItemsSource="{Binding Data.Words}" SelectionChanged="ListWord_SelectionChanged" &gt;
                  &lt;ListView.ItemTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;StackPanel&gt;                              
                              &lt;TextBlock Text="{Binding words}"/&gt;
                          &lt;/StackPanel&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/ListView.ItemTemplate&gt;
              &lt;/ListView&gt;                
          &lt;/StackPanel&gt;
          &lt;StackPanel Grid.Column="1" Grid.Row="1" Margin="40,0,0,0"&gt;
              &lt;TextBlock x:Name="KeyT" FontSize="30" &gt;&lt;/TextBlock&gt;
              &lt;TextBlock x:Name="ValueT" FontSize="20" &gt;&lt;/TextBlock&gt;
          &lt;/StackPanel&gt;            
      &lt;/Grid&gt;
  
  
  &lt;/Grid&gt;
  </code></pre>
  
  <p>
  And the code I want to call when typing:</p>
  
  <pre><code>private void SearchT_TextChanged_1(object sender, TextChangedEventArgs e)
      {
          if (SearchT.Text != "")
          {
              for (int i = ListWord.Items.Count - 1; i &gt;= 0; i--)
              {
                  var item = ListWord.Items[i];
                  if (item.ToString().Contains(SearchT.Text.ToString()))
                  {
  
                      //Display the item or scroll to it
  
                  }
                  else
                  {
                      //Do something here
                  }
              }
          }
      }
  </code></pre>