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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:45:40+00:00 2026-05-16T14:45:40+00:00

I am wiring up a WPF calendar to an MVVM view model. I’m not

  • 0

I am wiring up a WPF calendar to an MVVM view model. I’m not sure how to bind date selections and month changes to MVVM ICommand objects. For example to process a selected date change, what object would I bind in XAML to the appropriate command property in my view model?

As nearly as I can tell, I am stuck with event handling in code-behind. For example, it looks like the only way to detect a date selection change is to write a SelectedDatesChanged event handler. I can invoke the command property in my view model from the event handler, like this:

private void Calendar_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)
{
    var viewModel = (CalendarViewModel) DataContext;
    viewModel.GetDateNotes.Execute();
}

But I sense a code smell to that approach, unless there is no better approach available. Can anyone tell me how to bind a WPF Calendar to MVVM commands directly from XAML? Is there a better approach than the one I am taking? Thanks for your help.

  • 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-16T14:45:40+00:00Added an answer on May 16, 2026 at 2:45 pm

    Wouldn’t you have a DateTime property in your VM that is bound to the calendar and that raises PropertyChanged? If so, can’t you watch for property changed internally or write code in your setter so that you know when the view has changed its value?

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

Sidebar

Related Questions

Problems with wiring up datepicker The code for partial view @model System.DateTime @Html.TextBox(, Model.ToString(dd/MM/yy),
We are wiring up our views and view models externally meaning we have the
First I'm not mad, because I use MVVM in WinForms-) I know about MVP
My problem is not wiring up DependencyProperties in a UserControl . This is not
I have been getting my feet wet with MVVM pattern for WPF and everything
Not wanting to enter into the debate of wiring up event handlers in code
I'm working on a project which I'm really not sure how to unit test.
I have a question about wiring web server controls. From many of the examples
Is it possible to JUnit test if wiring by Spring is succesfully? I would
In my Asp.Net project I wanna use Property Auto-wiring, e.g. for my ILogger. Basically

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.