Flack
Flack

Reputation: 5899

Trying to setup a MultiBinding on an UnboundField in XamDataGrid

I tried the below. The first Binding is fine (it returns the rows DataItem as expected) but the second one results in an UnsetValue, giving the below error:

System.Windows.Data Warning: 40 : BindingExpression path error: 'igDP:Cell' property not found on 'object' ''ValueHolderWithDataContext' (HashCode=46875058)'. BindingExpression:Path=igDP:Cell.DataPresenter.DataContext; DataItem='ValueHolderWithDataContext' (HashCode=46875058); target element is 'ValueHolderWithDataContext' (HashCode=46875058); target property is 'Value' (type 'Object')

What I want the second binding to bind to is the xamdatagrid's (the one that the UnboundFiled is a part of) DataContext.

What do I need to change here?

                <igDP:UnboundField Name="Sample" Label="Sample">
                    <igDP:UnboundField.Binding>
                        <MultiBinding Converter="{StaticResource SampleConverter}">
                            <Binding/>
                            <Binding Path="igDP:Cell.DataPresenter.DataContext" RelativeSource="{RelativeSource Self}"/>
                        </MultiBinding>
                    </igDP:UnboundField.Binding>
                </igDP:UnboundField>

Upvotes: 0

Views: 449

Answers (1)

Ilan
Ilan

Reputation: 2782

The cause of the problem you have here is an incorrect binding definition. Since an UnboundField is a class which is bound to a certain DataType, the next binding part definition RelativeSource="{RelativeSource Self}" will return the DataContext(a certain DataType) the UnboundField is bound to it. So it will try to find the igDP:Cell property into the UnboundField object's DataContext. There is no a such property there, thus we'll get the BindingExpression error. The possible solution is to replace you binding part definition:

<Binding Path="igDP:Cell.DataPresenter.DataContext" RelativeSource="{RelativeSource Self}"/>

with the next one:

<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType=igDP:Cell}" Path="DataPresenter.DataContext"/>

Regards.

Upvotes: 1

Related Questions