Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
25
How do you manually bind to ObservableCollection of ObservableCollection ?
posted

I mean i need to bind unbound fields programmatically but i cannot manage to bind to a DataSource of type ObservableCollection<ObservableCollection<String>> sCol :

        <igDP:XamDataGrid x:Name="xamDataGrid" DataSource="{Binding sCol}">
            <igDP:XamDataGrid.FieldLayoutSettings>
                <igDP:FieldLayoutSettings AutoGenerateFields="False" />
            </igDP:XamDataGrid.FieldLayoutSettings>
            <igDP:XamDataGrid.FieldLayouts>
                <igDP:FieldLayout>
                    <igDP:FieldLayout.Fields>
                        <igDP:UnboundField Label="Col1" BindingPath="[0]" BindingMode="TwoWay" DataType="sys:String" />
                        <igDP:UnboundField Label="Col2" BindingPath="[1]" BindingMode="TwoWay" DataType="sys:String"/>
                    </igDP:FieldLayout.Fields>
                </igDP:FieldLayout>
            </igDP:XamDataGrid.FieldLayouts>
        </igDP:XamDataGrid>

Ouput traces say :

System.Windows.Data Error: 39 : BindingExpression path error: '[' property not found on 'object' ''EnumerableObjectWrapper' (HashCode=14407208)'. BindingExpression:Path=[1]; DataItem='EnumerableObjectWrapper' (HashCode=14407208); target element is 'a' (HashCode=44344604); target property is 'Value' (type 'Object')

I can achive a correct binding through a regular listView though :

        <ListView ItemsSource="{Binding sCol}">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Col1" DisplayMemberBinding="{Binding [0]}"/>
                    <GridViewColumn Header="Col2" DisplayMemberBinding="{Binding [1]}"/>
                </GridView>
            </ListView.View>
        </ListView>

It seems that the grid DataSource property does not behave like the list ItemsSource property.

What am I missing ?

Cheers.

Parents Reply Children
No Data