title: What is a good way to design a reusable query editor in WPF?
body: <p>I'm considering creating a pretty basic query editor (or it can be called data filter) that you can use to create basic queries with <code>AND</code> and <code>OR</code>. Like the following:</p>
  
  <p>(<code>FirstName</code> is equal to <code>Brown</code> AND <code>LastName</code> starts with <code>L</code>) OR <code>Age</code> is less than <code>10</code></p>
  
  <p>This will be a visual query editor, something like <a href="http://www.telerik.com/products/wpf/datafilter.aspx" rel="nofollow">Telerik's Data Filter</a>.</p>
  
  <p>I'm wondering how to design an API for such a control, so that it will be reusable and easily connectable to different situations.</p>
  
  <p><em><strong>What I was thinking was</em></strong> that the query editor would get the column names and column types at first. So maybe it can get something like <code>List&lt;KeyValuePair&lt;string, Type&gt;</code>.</p>
  
  <p>And then for my current project, I need to get a SQL representation, so there can be a method that returns the "WHERE" part of the SQL query. But this is not very reusable. If something else needs to use this control, it will need to parse the SQL statement returned by the control first.</p>
  
  <p>I'd like to get ideas from you, what could be a good way to make this thing reusable? In what form should it return the resulting query? I'm pretty new to WPF, so I'm wondering if there are some cool generic ways that I can use for the resulting query.</p>
  
  <p>And also I'm learning MVVM at the moment, so it would be nice if you could point me in directions as to how to make this thing usable in MVVM projects.</p>