Reputation: 39413
I'm looking for a MonthPicker control, a control just like a DatePicker but that you can only select the month and the year.
Before start writing one from scrath I would like to know if something like this exists.
Upvotes: 9
Views: 6285
Reputation: 39413
Finally made my own. It needs some polish, but works:
Usercontrol VB code at https://dl.dropboxusercontent.com/u/16351501/MonthPicker.zip
Upvotes: 1
Reputation: 4800
I have used System.Windows.Controls.Calendar in this way:
(that's in Hebrew, but I'd guess you got the Idea...)
XAML:
<Calendar Name="dteSelectedMonth" DisplayMode="Year" SelectionMode="None"
DisplayModeChanged="dteSelectedMonth_DisplayModeChanged" />
Code behind to keep calendar on Year mode:
private void dteSelectedMonth_DisplayModeChanged(object sender, CalendarModeChangedEventArgs e)
{
dteSelectedMonth.DisplayMode = CalendarMode.Year;
}
And I've used dteSelectedMonth.DisplayDate value to get the selected month.
You might want to insert that Calendar into an Expander or a ComboBox with binding to SelectedMonth
Upvotes: 4