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:
Using layout controls - a Grid control where each "cell" contains a ListView
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With