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
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.
Rob,
This is what I needed. Thank you very much. If the column type was a string and I wanted it to be an integer, would everything be the same except that sys:String would be sys:Integer?
Is there a listing of all of the igEditors and all the types somewhere?
Thanks again,
Mike.