title: Multiple bindings from ReactiveUI search using ObservableAsPropertyHelper<>
body: <p>I have a working implementation of a ReactiveUI asynchronous search routine within an WPF MVVM application based off of the following (legacy) example: </p>
  
  <p><a href="http://blog.paulbetts.org/index.php/2010/07/05/reactivexaml-series-implementing-search-with-observableaspropertyhelper/" rel="nofollow">http://blog.paulbetts.org/index.php/2010/07/05/reactivexaml-series-implementing-search-with-observableaspropertyhelper/</a></p>
  
  <pre><code>public class TheViewModel : ReactiveObject
  {
      private string query;
  
      private readonly ObservableAsPropertyHelper&lt;List&lt;string&gt;&gt; matches;
  
      public TheViewModel()
      {
          var searchEngine = this.ObservableForProperty(input =&gt; input.Query)
                  .Value()
                  .DistinctUntilChanged()
                  .Throttle(TimeSpan.FromMilliseconds(800))
                  .Where(query =&gt; !string.IsNullOrWhiteSpace(query) &amp;&amp; query.Length &gt; 1);
  
          var search = searchEngine.SelectMany(TheSearchService.DoSearchAsync);
  
          var latestResults =
              searchEngine.CombineLatest(search, (latestQuery, latestSearch) =&gt; latestSearch.Query != latestQuery ? null : latestSearch.Matches)
                  .Where(result =&gt; result != null);
  
          matches = latestResults.ToProperty(this, result =&gt; result.Matches);
      }
  
      public string Query
      {
          get
          {
              return query;
          }
          set
          {
              this.RaiseAndSetIfChanged(ref query, value);
          }
      }
  
      public List&lt;string&gt; Matches
      {
          get
          {
              return matches.Value;
          }
      }
  } 
  </code></pre>
  
  <p>The ReactiveXAML is working as expected and I can easily bind to the Matches property like so</p>
  
  <pre><code>&lt;ListBox Grid.Row="1" Margin="6" ItemsSource="{Binding Matches}" /&gt;
  </code></pre>
  
  <p>However I would like to refactor TheSearchService.DoSearchAsync() to return a more complex result structure sort of like this:</p>
  
  <pre><code>public class SearchResult
  {
      public string Query { get; set; }
      public List&lt;string&gt; Matches { get; set; }
      public int MatchCount { get; set; }
      public double SearchTime { get; set; }
  }
  </code></pre>
  
  <p>The matches would still be represented as a <code>List&lt;string&gt;</code> which would be bound to the same ListBox but I'd like also like to bind to a string metadata property on each search that returns the match count and search time in some sort of format such as:</p>
  
  <pre><code> string.Format("Found {0} matches in {1}s", x.MatchCount, x.SearchTime)
  </code></pre>
  
  <p>How could I change the ViewModel implementation to allow multiple bindings for each search?</p>
  
  <p><strong>Working implementation based on accepted answer</strong></p>
  
  <pre><code>public class TheViewModel : ReactiveObject
  {
      ...
  
      private readonly ObservableAsPropertyHelper&lt;SearchResult&gt; results;
  
      public TheViewModel()
      {
          ...
  
          var latestResults = searchEngine.CombineLatest(search, (latestQuery, latestSearch) =&gt; latestSearch.Query != latestQuery ? null : latestSearch)
                  .Where(result =&gt; result != null);
  
          results = latestResults.ToProperty(this, result =&gt; result.Result);
      }
  
      ...
  
      public SearchResult Result
      {
          get
          {
              return results.Value;
          }
      }
  }
  </code></pre>
  
  <p><strong>Here is the view</strong></p>
  
  <pre><code>&lt;StackPanel&gt;
      &lt;TextBox Text="{Binding Query, UpdateSourceTrigger=PropertyChanged}"
               Margin="6"
               FontSize="26" /&gt;
      &lt;TextBlock&gt;
          &lt;TextBlock.Text&gt;
              &lt;MultiBinding StringFormat="Found {0} matches in {1}s"&gt;
                  &lt;Binding Path="Result.MatchCount" /&gt;
                  &lt;Binding Path="Result.SearchTime" /&gt;
              &lt;/MultiBinding&gt;
          &lt;/TextBlock.Text&gt;
      &lt;/TextBlock&gt;
  &lt;/StackPanel&gt;
  &lt;ListBox Grid.Row="1"
       Margin="6"
       ItemsSource="{Binding Result.Matches}" /&gt;
  </code></pre>