How can I access the selected dates in a calendar control in my viewmodel?

Topics: Conventions, Getting Started, UI Architecture
Oct 8, 2012 at 8:03 PM

With a datagrid, I can change the x:Name to the property in my viewmodel and make that property a BindableCollection.

To access selected dates in a calendar control, can I set the x:Name for the calendar control?  What sort of property do I make in the viewmodel?  A BindableCollection<DateTime>?

Oct 8, 2012 at 8:26 PM

Ah, my datagrid binding isn't the same as what I want.  Rather than have something pushed out to the view, which is what my datagrid binding is doing, I want to access something from the view in my viewmodel.  So my question remains the same, I'm just really in the dark about the solution: how do I access selected dates from a calendar control in the view, in the viewmodel?

Oct 30, 2012 at 5:22 AM

I was able to access the selected dates in my view model by connecting a method to the SelectedDatesChanged event on the calendar and pass the SelectedDates collection as a parameter. I posted the solution here:

http://stackoverflow.com/questions/12788484/how-do-i-access-selected-dates-in-a-calendar-control-in-my-viewmodel

I haven't found a way to bind directly therefore the above solution only works once a selection is made by the user.