tags:

views:

48

answers:

3

Hello,

I need to display a complete calendar (12 months, 31~ days/month) on screen. Currently, I'm using a 12-column grid, with each column filled with a "months" stackpanel.
Each "month" stackpanel is filled with 31 (or less) day representations.
Each day representation is composed of a DockPanel embedding three controls :

  • a textblock to display the day letter
  • a textblock to display the day number
  • a textblock to display a short message

Of course, performances are crushed down when I try to resize the window.

Is there a useful trick to allow a fast display of many textblocks ?

+3  A: 

Have you looked at the Calendar Control? It's part of the WPF Toolkit if you're running .NET 3.5 or earlier and included as part of .NET 4

ChrisF
and part of WPF4
Jesus Rodriguez
@Jesus - I wasn't 100% sure, which is why I left that bit out. I'll update the answer.
ChrisF
A: 

Actually, I was trying to build a calendar UI from scratch, in order to control any part of it. I've done it using a grid with 12 colums and 31 rows, as the ItemsPanel of an ItemsControl. According to the data (day collection) bound to the ItemsControl, the grid places a DataTemplate in the right column/row pair.

Aurélien Ribon
+1  A: 

The fastest way is to subclass FrameworkElement (or maybe even Visual), override OnRender and draw the entire calendar in code.

But then you'll have to give up all the nice features templates give you, read this article first.

Nir
Thanks for the answer. I knew this article, and am a huge fan of DrawingVisuals :)But I need event, template, and animation support, and I have only 372 controls to show, not thousands. What I did was building a "DelayedGrid" control, which only calls the ArrangeOverrides method if the last call happened more than 0.5 second ago. This allows a quite responsive UI even when the user wants to resize everything.
Aurélien Ribon