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
65
Bind same property multiple times
posted

Hi,

I'm having trouble with the XamDataGrid component when I try to bind multiple columns to the same property of an object.

Let's assume we have this class : 

public class Person{

   public string Name{get;set;}

}

And a simple XamDataGrid like this :

<igWPF:XamDataGrid>
 <igWPF:XamDataGrid.FieldLayoutSettings>
        <igWPF:FieldLayoutSettings AutoGenerateFields="False" />
    </igWPF:XamDataGrid.FieldLayoutSettings>

      <igWPF:XamDataGrid.FieldLayouts>
          <igWPF:FieldLayout>
              <igWPF:Field Name="Name" Label="Name" />
              <igWPF:Field Name="Name" Label="Name" />
          </igWPF:FieldLayout>
      </igWPF:XamDataGrid.FieldLayouts>

</igWPF:XamDataGrid>

When I execute this I have a System.NotSupportedException thrown, with the following message : 

Field named Name was not found in data source: Test.Person

Do you have any idea on how I could use twice the same column in the same XamDataGrid ? (Of course I'm not only showing twice the same columns for fun, I need it because one of them will use a converter).

Thank you for your help.

ps : Sorry for my English, I'm French.

Parents
No Data
Reply
  • 2151
    Offline posted

    Hello Mickael,

     

    Thank for your post. You may define additional fields bound to the same data object's property by setting their BindingType property to "UseAlternateBinding" and specify the required field in their AlternateBinding property.

     

    Here is an example:

    <igDP:TextField BindingType="UseAlternateBinding" AlternateBinding="{Binding Path=Name}" Label="Second Time Name" />

     

    You can also read more information on this matter at the following locations:

    http://help.infragistics.com/doc/WPF?page=xamDataPresenter_Binding_Field_FieldLayout_to_MVVM.html

    http://help.infragistics.com/doc/WPF?page=xamDataPresenter_Add_Unbound_Fields_to_a_DataPresenter_Control.html

     

    I am also attaching a sample application showing three field definitions to one data object's property.

     

    Please do not hesitate to let me know if you have any further questions on this matter.

     

    Sincerely,

    Radko Kolev

    Infragistics

    www.infragistics.com/support

    WpfApplication1.zip
Children