0

I'm binding a collection of collections to a WPF datagrid component(external library) and the underlying DataSource has the following structure. This basically gives me a datagrid with hierarchical records

class DataGridItemType
{
    public string weightType;
    public string SourceType;
    private BindingList<DataGridItem> typeCollection = new BindingList<DataGridItem>();
}


BindingList<DataGridItemType> list = new BindingList<DataGridItemType>();

list is the datagrids DataSource and this performs hierarchical binding. Now, I tried binding a component(The header label of the records one level into the hierarchy whose datasource is typeCollection) to the variable weightType by using, Text="{Binding Path=weightType, Mode=TwoWay, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type btm:DataGridItemType}}} but the binding doesn't work. Am I missing something?

4

1 回答 1

0

AncestorType 应该是 UI 层次结构中要绑定到其 DataContext(这将是 DataGridItemType 的对象 - 您的自定义类)的 UI 元素。

这里没有代码片段,但请阅读此处的备注部分

于 2011-03-03T05:59:58.780 回答