title: I find an item in a WPF ListBox by typing
body: <p>Hi would like find an item in listbox by typing, I find many examples, but I think something I do bad.</p>
  
  <p>I bind to the listbox my  dictionary. Friend is my class, it look like this:</p>
  
  <pre><code> [JsonObject]
      [Export]
      public class Friend
      {
          public override string ToString()
          {
              return Nick;
          }
  
          [JsonProperty("idUser")]
          public string IdUser { get; set; }
  
          [JsonProperty("nick")]
          public string Nick { get; set; }
  
          [JsonProperty("sefNick")]
          public string SefNick { get; set; }
  
          [JsonProperty("isFriend")]
          public bool IsFriend { get; set; }
  
          [JsonProperty("status")]
          public int Status { get; set; }
  
      }
  </code></pre>
  
  <p>I have own data template on listbox here is it:</p>
  
  <pre><code> &lt;Style x:Key="friendsListStyle" TargetType="{x:Type ListBox}"&gt;
          &lt;Setter Property="ItemTemplate"&gt;
              &lt;Setter.Value&gt;
                  &lt;DataTemplate&gt;
                      &lt;Grid Name="RootLayout"&gt;
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition Width="0.3*"&gt;&lt;/ColumnDefinition&gt;
                              &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
                          &lt;Grid.RowDefinitions&gt;
                              &lt;RowDefinition Height="60"&gt;&lt;/RowDefinition&gt;
                          &lt;/Grid.RowDefinitions&gt;
                          &lt;Image Margin="4,4,4,2" Grid.Column="0"&gt;
                              &lt;Image.Source &gt;
                                  &lt;MultiBinding Converter="{StaticResource imageConverter}"&gt;
                                      &lt;Binding Path="Value.ProfilePhoto"&gt;&lt;/Binding&gt;
                                      &lt;Binding Path="Value.Status"&gt;&lt;/Binding&gt;
                                  &lt;/MultiBinding&gt;
                              &lt;/Image.Source&gt;
                          &lt;/Image&gt;
                          &lt;Grid  Grid.Column="1"&gt;
                              &lt;Grid.ColumnDefinitions&gt;
                                  &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
                              &lt;/Grid.ColumnDefinitions&gt;
                              &lt;Grid.RowDefinitions&gt;
                                  &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
                                  &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
                                  &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
                              &lt;/Grid.RowDefinitions&gt;
                              &lt;TextBlock 
                                     Text="{Binding Value.Nick}" 
                                     Margin="2,2,2,2" 
                                     FontSize="13" 
                                     FontWeight="Medium"
                                     Grid.Column="0" Grid.Row="0"&gt;
                              &lt;/TextBlock&gt;
                              &lt;TextBlock  
                                     Text="{Binding Value.BlockQuote}"
                                     FontSize="11" 
                                     FontWeight="Normal" 
                                     Foreground="DarkGray"
                                     Grid.Column="0" Grid.Row="1" Margin="2,2,2,2"&gt;&lt;/TextBlock&gt;
                              &lt;TextBlock  
                                     Text="{Binding Value.Status,Converter={StaticResource statusConverter}}"
                                     Style="{StaticResource StatusStyle}"
                                     Grid.Column="0" Grid.Row="2" &gt;
                              &lt;/TextBlock&gt;
                          &lt;/Grid&gt;
                      &lt;/Grid&gt;
                      &lt;DataTemplate.Triggers&gt;
                          &lt;Trigger Property="IsMouseOver" Value="true"&gt;
                          &lt;Setter Property="LayoutTransform" TargetName="RootLayout"&gt;
                              &lt;Setter.Value&gt;
                                  &lt;ScaleTransform ScaleX="1.25" ScaleY="1.25" /&gt;
                              &lt;/Setter.Value&gt;
                          &lt;/Setter&gt;
                      &lt;/Trigger&gt;
                      &lt;/DataTemplate.Triggers&gt;
                  &lt;/DataTemplate&gt;
              &lt;/Setter.Value&gt;
  </code></pre>
  
  <p>I apply this template on listbox:</p>
  
  <pre><code>&lt;ListBox Name="Friends" 
           SelectedIndex="{Binding Path=SelectedFriendsIndex,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
           SelectedItem="{Binding Path=SelectedFriend, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"
           Style="{DynamicResource friendsListStyle}"
           IsTextSearchEnabled="True" TextSearch.TextPath="Nick"
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>I enable text search I want search by Nick, Nick is string property of Friend class:</p>
  
  <pre><code>IsTextSearchEnabled="True" TextSearch.TextPath="Nick"
  </code></pre>
  
  <p>But it doesn’t works. I examples I find only that you must enable IsTextSearchEnabled and set TextSearch.TextPath on string property of item object.</p>
  
  <p>What I do bad. Thank for advice.</p>