Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 81789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:30:54+00:00 2026-05-10T21:30:54+00:00

This one has me beat; I have a WPF window with two (important for

  • 0

This one has me beat;

I have a WPF window with two (important for this case) controls, both from the WPF toolkit available at CodePlex; A DatePicker and a DataGrid.

The DataContext of this window is set to a CLR object that has all the information it needs. This CLR object has a large list of data, and a method called GetDataForDate( DateTime date ) which decides which date we will see data for.

How can I create a ObjectDataProvider (which I assume will be the correct solution) that the datagrid can bind to, which provides access to the data returned by GetDataForDate() called with the selected date of the DatePicker as the parameter?

In other words, I want the user to use the datepicker to choose a date, and the grid should automatically update whenever the date is changed to reflect the correct data.

What kind of black magic do I have to do to achieve something like this – which I would guess should be a relatively common databinding scenario?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:30:55+00:00Added an answer on May 10, 2026 at 9:30 pm

    Here is my complete code. I hope this will help.

    The xaml code:

    <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'>     <Window.Resources>         <ObjectDataProvider ObjectInstance='_this.DataContext'                             MethodName='GetFromDate'                             x:Key='odp'>             <ObjectDataProvider.MethodParameters>                 <System:DateTime>2008-01-01</System:DateTime>               </ObjectDataProvider.MethodParameters>         </ObjectDataProvider>     </Window.Resources>     <Grid>         <Grid.RowDefinitions>             <RowDefinition Height='Auto'/>             <RowDefinition Height='*'/>         </Grid.RowDefinitions>          <dg:DatePicker Grid.Row='0' x:Name='dtpSource' >             <dg:DatePicker.SelectedDate>                 <Binding Source='{StaticResource odp}'                          Path='MethodParameters[0]'                                 BindsDirectlyToSource='True'                               Mode='OneWayToSource'/>             </dg:DatePicker.SelectedDate>         </dg:DatePicker>          <dg:DataGrid x:Name='dtgGrid'                           ItemsSource='{Binding Source={StaticResource odp}}'                           AutoGenerateColumns='True'                           Grid.Row='1'/>     </Grid> </Window> 

    The code behind:

    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;     } } 

    and the business object:

    public class DataItem {     public string Name { get; set; }     public int BirthYear { get; set; } }  public class Data {     private readonly List<DataItem> data;      public Data()     {         data = new List<DataItem>();         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<DataItem> GetFromDate(DateTime dt)     {         return this.data.Where(d => d.BirthYear == dt.Year).ToList();     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 61k
  • Answers 61k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer That's something you could very well solve with WF (Workflow… May 11, 2026 at 9:39 am
  • added an answer This way (VB.NET code): For Each dkn As String in… May 11, 2026 at 9:39 am
  • added an answer Sorry... WPF's implementation of the EventTrigger only allows one routed… May 11, 2026 at 9:39 am

Related Questions

This one has me beat; I have a WPF window with two (important for
This one has me kind of stumped. I want to make the first word
This one has me scratching my head. I'm running Subversion 1.3.1 (r19032) on Ubuntu.
This one has me puzzled. It seemed like an easy task, but the solution
This one has been bugging me for a while now. Is there a way
Alright, this one (3a; sample problem with provided answer) has got me scratching my
Has any one done this before? It would seem to me that there should
This one has us all baffled at work. We have two services running on
This question has spawned out of this one. Working with lists of structs in
Let's say you have a text file like this one: http://www.gutenberg.org/files/17921/17921-8.txt Does anyone has

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.