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

  • SEARCH
  • Home
  • 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 am interested in developing something that will make use of Chinese handwritten recognition
This is something that I don't see much discussed. I'm developing a software that
I'm currently developing a program that will generate reports based upon lead data. My
We are developing a system that will do financial statements and other financial-related things.
Disclaimer:It's my first time developing an app that will be on a tablet style
I'm developing a class library in .NET that other developers will consume eventually. This
I'm developing an add on to a system I have that will allow my
I'm currently developing a MVC3 web application that needs to require extranet users to
I am developing an application that will be capable of handling multiple file types.
I'm developing a database-connected Linux daemon in C++ that will act as a server

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.