I'm working on a control for one of our apps. The control shows the currently focused day as a gird, the X-axis being time of day. The Y axis doesn't have a scale as such, rather it will separate out the items to be displayed. The overall look of the control will be quite similar to a gantt chart, showing the times of day of various tasks. For a (very rough) idea, see the ascii (not) art below.
8 9 10 11 12 1 2 3 4 5 6
-----------------------------------------------------------------------------
| | | | | | | | | | |
| ====================== | | | | | |
| | | ====================== | | | |
| | | | | | | ======== | |
| | | | ===========================================
| | | | | | | | | | |
I have the background grid worked out so that it is resizable, and has a "current time" indicator implemented as a vertical blue line to show where we are in relation to the tasks. When the control is resized, the current time indicator's position is recalculated to ensure it shows the right time.
What I am now unsure of is how to implement the horizontal bars that represent the task items. I have a task entity with start time, end time, name and description and I'd like the control to contain a collection of these entities. I'd also like these entities to drive the display.
My exposure to WPF is quite limited, but in the past my attempts at visualising a collection of objects has involved using a listbox and datatemplates. It would be great if it was possible to bind a collection to a stack panel or something similar so I could have semothing like this. (I though StackPabnel since it would handle vertical stacking for me)
<UserControl declarations here... >
<UserControl.Resources>
<ObjectDataProvider x:Key="myCollection" />
</UserControl.Resources>
<Grid Name="myBackgroundGrid" Margin="0,0,0,0" ... >stuff goes here to draw the background</Grid>
<StackPanel ItemsSource="{Binding Source={StaticResource myCollection}}" />
</UserControl>
Can anyone tell me if what I thought of here is even possible, and (hopefully) give me some guidance as to how to achieve what I want to do.
Thanks in advance.
--EDIT--
The "control" that displays each task doesn't have to be anything more complicated than a line with a start and end time, and a tooltip of the name of the task. For the time being, I don't need to be able to drill into tasks, although this may come later.