Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is my complete code. I hope this will help.</p> <p>The xaml code:</p> <pre><code>&lt;Window x:Class="DataGridSort.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dg="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit" xmlns:System="clr-namespace:System;assembly=mscorlib" Title="Window1" Height="413" Width="727" x:Name="_this"&gt; &lt;Window.Resources&gt; &lt;ObjectDataProvider ObjectInstance="_this.DataContext" MethodName="GetFromDate" x:Key="odp"&gt; &lt;ObjectDataProvider.MethodParameters&gt; &lt;System:DateTime&gt;2008-01-01&lt;/System:DateTime&gt; &lt;/ObjectDataProvider.MethodParameters&gt; &lt;/ObjectDataProvider&gt; &lt;/Window.Resources&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;RowDefinition Height="*"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;dg:DatePicker Grid.Row="0" x:Name="dtpSource" &gt; &lt;dg:DatePicker.SelectedDate&gt; &lt;Binding Source="{StaticResource odp}" Path="MethodParameters[0]" BindsDirectlyToSource="True" Mode="OneWayToSource"/&gt; &lt;/dg:DatePicker.SelectedDate&gt; &lt;/dg:DatePicker&gt; &lt;dg:DataGrid x:Name="dtgGrid" ItemsSource="{Binding Source={StaticResource odp}}" AutoGenerateColumns="True" Grid.Row="1"/&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>The code behind:</p> <pre><code>public partial class Window1 : Window { public Window1() { InitializeComponent(); LoadData(); } protected void LoadData() { DataContext = new Data(); ObjectDataProvider odp = this.Resources["odp"] as ObjectDataProvider; odp.ObjectInstance = DataContext; } } </code></pre> <p>and the business object:</p> <pre><code>public class DataItem { public string Name { get; set; } public int BirthYear { get; set; } } public class Data { private readonly List&lt;DataItem&gt; data; public Data() { data = new List&lt;DataItem&gt;(); data.Add(new DataItem { Name = "John", BirthYear = 2007 }); data.Add(new DataItem { Name = "Mike", BirthYear = 2007 }); data.Add(new DataItem { Name = "Aaron", BirthYear = 2006 }); data.Add(new DataItem { Name = "Bill", BirthYear = 2006 }); data.Add(new DataItem { Name = "Steven", BirthYear = 2005 }); data.Add(new DataItem { Name = "George", BirthYear = 2004 }); data.Add(new DataItem { Name = "Britany", BirthYear = 2004 }); } public List&lt;DataItem&gt; GetFromDate(DateTime dt) { return this.data.Where(d =&gt; d.BirthYear == dt.Year).ToList(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload