Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In WPF, what is the best way to create a calendar view similar to Outlook 2007?

I'm writing a WPF desktop application and have a view that needs to look like a calendar. I only need to show four weeks (fixed). Each week will have a list of items (probably represented with a ListView). I'm debating between two approaches:

  1. Using layout controls - a Grid control where each "cell" contains a ListView

  2. Using a ListView + GridView and then customizing the style to look more like a calendar

In my opinion, the layout controls would be easier to implement but something about it feels dirty. I would essentially be hard-coding 28 cells each containing a ListView. But again, it would be simple.

I'm thinking the ListView/GridView would be more elegant, but I still need to create a ListView for each cell and then I have to figure out how to style the control in such a way that it looks more like a calendar and less like a table.

Thoughts?

like image 707
Jordan Parmer Avatar asked Nov 25 '25 06:11

Jordan Parmer


1 Answers

You could use a ListBox, with a UniformGrid. That would take care of building the base layout. With a little triggering on the current month to implement the change of style when the displayed day is not in the current month.

Then, each day can have a ListView or ListBox as part of its template, for displaying tasks/meetings/whatever.

The whole thing would bind to a collection of objects that represents the "days" and their content.

ListBox is usually a good bet for the base of an ItemsControl.

You should also have a look at how the Calendar control is built in WPF, it might help give you some ideas.

like image 67
Denis Troller Avatar answered Nov 26 '25 19:11

Denis Troller



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!