Eduardo Molteni
Eduardo Molteni

Reputation: 39413

Do you know a WPF MonthPicker control?

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

Answers (3)

Eduardo Molteni
Eduardo Molteni

Reputation: 39413

Finally made my own. It needs some polish, but works:

alt text

Usercontrol VB code at https://dl.dropboxusercontent.com/u/16351501/MonthPicker.zip

Upvotes: 1

itsho
itsho

Reputation: 4800

I have used System.Windows.Controls.Calendar in this way:

Calendaer used as MonthPicker

(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

benPearce
benPearce

Reputation: 38333

The WPF Toolkit DatePicker can have its Calendar re-styled.

You could also override the string format on the textbox in the DatePicker to only display the Month and Year.

You can see some examples and discussion here.

Upvotes: 0

Related Questions