需要一个“网格”用作日历的堆栈面板
最终,我的目标是拥有一个由小型堆栈面板组成的网格(我所说的网格是指行和列,无论它是如何实现的)来表示一天中的时间间隔。我认为与以下内容不太相似(右侧的简单日历类型布局):
(来源:msdn.com)
我需要一种动态创建此网格并在事件触发时适当命名面板的方法(具体来说 -放置事件,每个面板的放置事件将连接到相同的方法,在该方法中我必须区分项目被放置在哪个面板上(即在一天中的什么时间点,以及在哪一行)。
非常感谢您的帮助!
担
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能无法从此处获得执行此操作的完整代码,但我可以为您指出正确的方向。
您可能想要使用嵌套的 ItemsControl。我过去做过类似的事情,日历的外部
ItemsControl
是一个Grid
,网格单元格包含一个内部ItemsControl
和一个TaskItems
的StackPanel
。最重要的部分是让数据层正确。我使用了
CalendarDayModel
类,它具有Date
属性和ObservableCollection
列表。它还具有处理用户事件的命令,例如双击事件。我的外部
ItemsControl
绑定到ObservableCollection
,内部ItemsControl
绑定到ObservableCollection
>我有一些 ItemsControl 的示例 此处,但请注意最后一个使用网格的示例。
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 aGrid
, and grid cell contained an innerItemsControl
with aStackPanel
ofTaskItems
.The most important part is getting your data layer right. I used
CalendarDayModel
classes, which had aDate
property and anObservableCollection<TaskModel>
list. It also had Commands to handle user events, such as double-click events.My outer
ItemsControl
was bound to theObservableCollection<CalendarDayModel>
and the innerItemsControl
were bound to theObservableCollection<TaskModel>
I have some examples of an ItemsControl here, but take note of the last example that uses a Grid.