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
640
XamTreeGrid: Is it possible to provide a multibinding to an AlternateBind DP?
posted

Infragistics team,

Here we trying to provide a specific value based on whether a Checkbox control is checked.

The same to value works as expected in separate columns in the snippet below

Thanks,

Michael

Snippet

<igDP:TextField Label="Order Status Multi"

Name="Status2"

BindingType="UseAlternateBinding">

<igDP:TextField.AlternateBinding>

<MultiBinding Converter="{StaticResource HeatmapCombineTextConverter}">

<Binding Path="DataItem.Status RelativeSource={RelativeSource AncestorType={x:Type igDP:XamTreeGrid}}" />

<Binding Path="DataItem.StickyStatus RelativeSource={RelativeSource AncestorType={x:Type igDP:XamTreeGrid}}" />

<Binding ElementName="HeatMapViewCheckBox"

Path="IsChecked" />

</MultiBinding>

</igDP:TextField.AlternateBinding>

<igDP:TextField.Settings>

<igDP:FieldSettings CellValuePresenterStyle="{StaticResource TextFieldStyle}" />

</igDP:TextField.Settings>

</igDP:TextField>

<igDP:TextField AlternateBinding="{Binding Status}"

Label="Order Status"

Name="Status">

<igDP:TextField.Settings>

<igDP:FieldSettings CellValuePresenterStyle="{StaticResource TextFieldStyle}" />

</igDP:TextField.Settings>

</igDP:TextField>

<igDP:TextField AlternateBinding="{Binding StickyStatus}"

Label="StickyStatus"

Name="StickyStatus">

<igDP:TextField.Settings>

<igDP:FieldSettings CellValuePresenterStyle="{StaticResource TextFieldStyle}" />

</igDP:TextField.Settings>

</igDP:TextField>

Parents
No Data
Reply
  • 34810
    Offline posted

    Hello mdperini,

    I would imagine at the moment, that the MultiBinding that you are using is currently not firing the convert method of your IMultiValueConverter. This would be because all three of the bindings that you currently have set for your MultiBinding are invalid.

    The first two bindings are trying to use a RelativeSource AncestorType binding to get up to the XamTreeGrid and are trying to bind to DataItem.Status/StickyStatus properties. The XamTreeGrid does not have a DataItem property, and so this will not work. Although, this would not work anyway, as the TextField in the XamTreeGrid is not a visual element, and so it has no visual "Ancestor" in this case. This is also the reason why your third, ElementName binding will not work, as the TextField needs to be a visual element to get a reference to another visual element by name.

    The "object" used for an AlternateBinding happens internally, and it returns an object of the type ValueHolderWithDataContext. This ValueHolderWithDataContext object has a data context of the data item that makes up a particular row in the XamTreeGrid. So, if your underlying data object has a property named "StickyStatus", or "Status" you can use the following bindings to pass these properties to your IMultiValueConverter used for the Converter property of your MultiBinding:

    <Binding Path="StickyStatus" />
    <Binding Path="Status" />

    The ElementName binding is a bit trickier. You will not be able to get to your Checkbox using an ElementName due to the limitation of the fields not being visual elements as mentioned before, and so you will not be able to bind directly to its IsChecked property. Instead, I would recommend that you bind its IsChecked property to a bool property on the data context of the XamTreeGrid. This will allow you to use the following binding to get whether or not the checkbox is checked:

    <Binding RelativeSource={RelativeSource Self}, Path=Cell.Field.Owner.DataPresenter.DataContext.CheckedProperty />

    Breaking the above Binding down, the RelativeSource Self will get you the ValueHolderWithDataContext object. This object has a Cell property, as this AlternateBinding will be evaluated for each Cell in the grid, and it returns the current cell being evaluated. The cells have a Field property that return the Field that they belong to. The Fields have an Owner property that returns the FieldLayout it belongs to, which then returns the XamTreeGrid via the DataPresenter property. In this case, the DataContext of the XamTreeGrid would have a bool property named "CheckedProperty" that the IsChecked property of the Checkbox is bound to, which would pass the checked value of the Checkbox to your converter.

    I have attached a sample project to demonstrate the above. I hope this helps you.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

    XamTreeGridAlternateMultiBindingCase.zip
Children
No Data