CompositeCollection + CollectionContainer:将CollectionContainer.Collection绑定到ViewModel的属性,该属性用作DataTemplates DataType
我没有获得正确的Binding语法来访问在其资源中定义CompositeCollection
的MyViewModel
中的DateTemplate
的Cats
and Dogs
属性。
public class MyViewModel { public ObservableCollection Cats { get; private set; } public ObservableCollection Dogs { get; private set; } }
我要为????插入什么? 将Dogs
and Cats
集合绑定到CollectionContainer
s?
由于http://Conocial.msdn.microsoft.com/Forums/vstudio/en-US/b15cbd9d-95aa-47c6-8068-7ae9f7dca88a/collectioncontainer-does-not-support-relativesource所述的CollectionContainer
上的数据绑定问题?forum = wpf我现在使用以下方法:
编辑: CompositeCollection
类不派生自FrameworkElement
,因此没有DataContext
属性来支持数据绑定。 它只有在使用Binding
提供Source
时才有效。 有关更多信息,请查看https://stackoverflow.com/a/6446923/1254795 。
尝试为ListBox指定名称并在绑定中引用其DataContext:
- 排序日期和时间
- 如何在不写入文件的情况下获取DataVisualization.Charting.Chart到iTextSharp.text.Image的图像?
- c#窗体格式DataTable with Image列排序
- c#中的全局exception处理(控制台应用程序)
- Silverlight Assembly.Load()仅适用于完整/强名称
- 所有文件夹中的Exchange Web服务(EWS)FindItems
- “以管理员身份运行”时,实例化COM组件失败并显示“未注册类”
- 为什么Int32.MaxValue * Int32.MaxValue == 1?
- 在TreeView中使用HierarchicalDataTemplates