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
2275
Difference between using FieldLayouts and FieldLayout
posted

 

 

When using:

<igDP:XamDataGrid.FieldLayouts>
	<igDP:FieldLayout>
	</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>

as opposed to:

 

<igDP:FieldLayout>
	<igDP:FieldLayout.Fields>
	</igDP:FieldLayout.Fields>
</igDP:FieldLayout>

 

The problem is that converters won't work with the first way of laying out fields as the column is always blank if the type returned by the converter is different than the type the column name maps to, and if you use the second way, you get the following exception:

Can't set the DataSource on a DataPresenter that has items added explicitly through the DataItems collection

We are binding to the SelectedItem in a combobox and we must use the second way of binding to prevent this exception. Currently, we're creating an additional column to match the type, and am writing code in our model to pass this information forward.  I'd prefer to use a converter.  Is there a way to get converters to work using the first way?

Thanks,

Mike Malter

Parents
  • 34510
    Verified Answer
    Offline posted

    Hi Mike,

    Does your converter return the same type every time?  If so you can set some settings on the FieldSettings property of the Field that will allow you use a different type than what the column name maps to.  The XAML code looks like this:

    <igDP:Field Name="UnitPrice" Label="Unit Price" Converter="{StaticResource priceconv}">
     <igDP:Field.Settings>
      <igDP:FieldSettings EditorType="{x:Type igEditors:XamTextEditor}" EditAsType="{x:Type sys:String}"/>
     </igDP:Field.Settings>
    </igDP:Field>

    This field is mapped to a Property that is of type double but my converter returns a string so in order to show this new value I told the text editor used within the cell to expect a string using the EditAsType property.

Reply Children