【发布时间】:2011-08-28 12:31:49
【问题描述】:
我在这里遇到了一些设计问题。
我有一个观点:
<ItemsControl x:Name="CellVMs">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Grid.Row"
Value="{Binding Position.Y}" />
<Setter Property="Grid.Column"
Value="{Binding Position.X}" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
它绑定到一组视图模型,这些视图模型具有一个位置属性,该样式使用该属性将其定位在 ItemPanelTemplate 上。 (每个单元格只有一个视图模型,并且网格单元格是固定大小的)
1) 我希望 Grid 是伪无限的,即添加和减去 EditorVM,Grid 应该动态添加和删除 Row\Col 定义,并且应该总是有足够的 Grid,并且应该总是有足够的填充父视图。
2) 在我的包含视图模型中,我导入了一个具有 Grid 属性的 IGridEditor 实现实例。如何将 ItemsPanelTemplateGrid 绑定到 IEditor.Grid?
现在,我在 IGridEditor 的方法中将 CellVM 添加到集合中,然后当包含 vm 导入实例时,将包含 vm 的 CellVM 集合设置为实例集合,并且项目控件使用 Caliburn.Micro 的约定绑定到该集合.
我正在使用 Caliburn.Micro\MEF 顺便说一句。
谁能帮我解决这个问题?
编辑:
一直在试图理解这一点,但我的想法是空的。
我唯一能找到的是
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid x:Name="EditorGrid"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
在我的视图中:
[Import("EditorGrid", typeof(Grid))]
public Grid EditorGrid { get; set; }
以及相应的类中的导出,该类具有将事物添加到网格的方法/
【问题讨论】:
标签: wpf data-binding mvvm