将 GridView ItemsSource 和 SelectedItem 绑定到泛型类型
我正在使用 Silverlight 4、RIA 服务、MEF 和 MVVM。
我正在尝试创建一个系统配置更新页面,以便我可以轻松更新我的查找表。 我有一个 RadGridView,我希望用它显示和添加来自多个实体的新记录。 我想使用以下内容:
ItemsSource="{Binding Path=GenericEntityList, Mode=TwoWay}"
SelectedItem="{Binding Path=SelectedEntity, Mode=TwoWay}"
由于我想让 GridView 可写,因此我无法将 ItemsSource 绑定到 CollectionViewSource.View - 正如我在 gridview 为只读的其他实例中所做的那样。 我想让 GenericEntityList 成为 ObservableCollection 或未知实体类型的列表,直到我选择给定的实体类型。 例如,如果我想使用同一网格编辑销售和产品,我如何才能推迟创建 GenericEntityType 类型或直到选择销售或产品之后?
实现此目的的一个很长的方法是在代码隐藏中动态添加 ItemsSource 和 SelectedItem 属性。问题是我有大约 25 个不同的实体,由于缺乏更好的词,这将变得“混乱”。
有什么建议吗?
I am using Silverlight 4, RIA Service, MEF and MVVM.
I am trying to create a system configuration update page so i can easily update my lookup tables.
I have a RadGridView with which I wish to display and add new records from multiple entities.
I want to use the following:
ItemsSource="{Binding Path=GenericEntityList, Mode=TwoWay}"
SelectedItem="{Binding Path=SelectedEntity, Mode=TwoWay}"
Since I want to make the GridView writeable, I cannot bind ItemsSource to CollectionViewSource.View -as I have done in other instances where my gridview is ReadOnly.
I want to have GenericEntityList be an ObservableCollection or List of unknown Entity type until i make a selection of a given Entity type.
For example, if i want to edit Sales and Products with this same grid, how can i defer making GenericEntityType of type or until AFTER i choose Sales or Product?
A long way to do this is to dynamically add the ItemsSource and SelectedItem properties in the codebehind. The problem is I have about 25 different entities and this will be 'untidy' for want of a better word.
Any suggestions ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想阅读动态关键字,例如
但是,我不确定是否所有第三方网格都支持绑定到动态数据。或者,您的查找对象是否可以不实现通用接口?
You may want to read up on the dynamic keyword e.g.
However, I'm not sure whether all third party grids support binding to dynamic data. Alternatively, could your lookup objects not implement a generic interface?