Ultimately, my aim is to have a grid (by grid I mean rows and columns, however it's achieved) of small stack panels to represent time intervals throughout a day. Not too disimilar from the following I suppose (simple calendar-type layout on the right):
(source: msdn.com)
I need a way of creating this grid dynamically and naming the panels appropriately for whenever an event is fired (to be specific - a drop event, each panel's drop event will be wired to the same method in which I must distinguish what panel (i.e. at what point in the day, and on what row) the item was dropped on).
Thanks a LOT for any help!
Dan
You probably won't get the full code to do that from here, but I can point you in the right direction.
You are probably going to want to use nested ItemsControl. I have done something like this in the past where my outer ItemsControl
for the Calendar was a Grid
, and grid cell contained an inner ItemsControl
with a StackPanel
of TaskItems
.
The most important part is getting your data layer right. I used CalendarDayModel
classes, which had a Date
property and an ObservableCollection<TaskModel>
list. It also had Commands to handle user events, such as double-click events.
My outer ItemsControl
was bound to the ObservableCollection<CalendarDayModel>
and the inner ItemsControl
were bound to the ObservableCollection<TaskModel>
I have some examples of an ItemsControl here, but take note of the last example that uses a Grid.