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
20
Append second bound value to a converted bound value in a field
posted

Hi,

I´ve got this code:

https://gist.github.com/anonymous/8ebc299a28856a4cdef2b55c417eb028

and in the field State i want to add a second bound value that is the date, problem is that the state is being returned by a converter:

<igDP:Field
Name="State" Width="120"
Converter="{StaticResource cnvEnumToText}"
Label="Status">
<igDP:Field.Settings>
<igDP:FieldSettings EditAsType="{x:Type sys:String}" />
</igDP:Field.Settings>
</igDP:Field>

Some tips on how to do this?

thanks in advance

  • 34430
    Offline posted

    Hello Ximo,

    In the sample “gist” that you had provided, you will not be able to append more information using the Field’s Converter, as the field is “Name-bound” to the State property of the underlying data item. As such, the values of this State property will be passed to the Converter. There are a couple of recommendations that I can make in order to allow you to do this, though.

    My first recommendation would be to use a TemplateField, which you can read about here: https://www.infragistics.com/help/wpf/xamdatagrid-configuring-template-field. Doing this would allow you to define a display template to show as many properties as you would like. Note, though, that the data context would still be the “name-bound” value in this case. However, using a RelativeSource AncestorType binding to the CellValuePresenter or TemplateEditor, you could bind to other properties on your underlying data item as well. An example binding could look like the following:

    {Binding RelativeSource={RelativeSource AncestorType={x:Type ig:CellValuePresenter}}, Path=DataContext.DataItem.Date}

    Breaking this binding down, it binds up to the CellValuePresenter element with a path of DataContext.DataItem.Date. The DataContext of the CellValuePresenter is the DataRecord in which it sits. This DataRecord has a DataItem property that returns the item it represents, and in this case, Date is a property on that item.

    An alternative to the TemplateField would be to use an AlternateBinding, which you can read about here: https://www.infragistics.com/help/wpf/xamdatapresenter-add-unbound-fields-to-a-datapresenter-control. If you define an AlternateBinding of simply “{Binding}” this will bind to the entire underlying data item of each of your records. Using the Converter property, you can then observe the entire data item and parse it, returning the properties that you wish to show.

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

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

    Sincerely,
    Andrew
    Associate Developer

    XDGSecondValueCase.zip