【发布时间】:2017-02-23 19:34:05
【问题描述】:
我有一个动态 DataGrid,其中 1 列包含 ComboBox 模板。现在我将获得“N”个组合框。每个 ComboBox 应该有不同的 ItemsSource。如何实现? 我的动态数据网格具有 ItemsSourceBinding 属性。现在我需要在运行时为此属性提供一个 DataContext.BindingName。如何实现?
column.ItemsSourceBinding = new Binding()
{
Path = new System.Windows.PropertyPath("DataContext." + bindStreamList1),
RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(DataGrid), 1)
};
代替bindStreamList1,我需要一个List<string> 的名称。它可能来自List<List<string>> 或来自Dictionary<string,List<string>>
【问题讨论】:
-
List<string>没有与之关联的名称,您的意思是要使用字典吗?向我们展示您的代码。 -
column.ItemsSourceBinding = new Binding() { Path = new System.Windows.PropertyPath("DataContext." + bindStreamList1), RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(DataGrid), 1) };代替“bindStreamList1”,我需要一个 List
的名称。它可能来自 List - > 或 Dictionary
> -
欢迎来到 Stack Overflow!请参阅How to Ask 和minimal reproducible example。
标签: c# wpf data-binding combobox datagrid