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 3340694
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:38:14+00:00 2026-05-18T00:38:14+00:00

I am developing something that will require similar functionality to the Silverlight DatePicker –

  • 0

I am developing something that will require similar functionality to the Silverlight DatePicker – a popup containing a Calendar control will be shown, and after the user clicks a date, or uses the keyboard to select a date and presses enter/space, the popup should close.

I can show the calender just fine, but I am at a loss at figuring out when the user has clicked a day or pressed enter/space. The SelectedDatesChanged event does not give any indication of whether the user clicked the selected date, or was just passing over it with the keyboard.

Reflector shows that the DatePicker control is cheating, using an internal DayButtonMouseUp event on the Calendar control.

Does anyone know a solution to this problem?

  • 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. Editorial Team
    Editorial Team
    2026-05-18T00:38:15+00:00Added an answer on May 18, 2026 at 12:38 am

    Not a very clean solution. Also, it does not properly take into account BlackoutDates because the IsBlackOut property of the button is also internal. I could manually check against that in my click event, but for my purposes I didn’t need to support that.

    void CalendarControl_Loaded(object sender, RoutedEventArgs e)
    {
        var grid = FindVisualChildByName<Grid>(CalendarControl, "MonthView");
        // Loaded may be called several times before both the grid and day buttons are created
        if (grid != null && grid.Children.OfType<System.Windows.Controls.Primitives.CalendarDayButton>().Any()) 
        {
            // Add our own click event directly to the button
            foreach (var button in grid.Children.OfType<System.Windows.Controls.Primitives.CalendarDayButton>().Cast<System.Windows.Controls.Primitives.CalendarDayButton>())
            {
                button.Click += new RoutedEventHandler(button_Click);
            }
            // We only want to add the event once
            CalendarControl.Loaded -= new RoutedEventHandler(CalendarControl_Loaded);
        }
    }
    
    void button_Click(object sender, RoutedEventArgs e)
    {
        var button = (System.Windows.Controls.Primitives.CalendarDayButton)sender;
        var date = button.DataContext as DateTime?;
        // The user clicked a date. Close the calendar and do something with it
    }
    

    FindVisualChildByName is copied from http://pwnedcode.wordpress.com/2009/04/01/find-a-control-in-a-wpfsilverlight-visual-tree-by-name/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a web application that will enable users to post short status updates
I'm developing a class library in .NET that other developers will consume eventually. This
I'll be developing something for a Windows Mobile device using CompactFramework/C#. I wonder if
When developing a desktop application in .NET, is it possible to not require the
We are developing an ASPX (.NET 2.0) page that includes a select list with
I'm currently in the process of developing a fairly large static library which will
Developing websites are time-consuming. To improve productivity, I would code a prototype to show
Developing a .NET WinForms application: how can I check if the window is in
Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux.
Developing a website and just trying to get back into the swing of (clever)

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.