Hi all, I'm trying to create a xamDataGrid where the last field is extended, and also allows for text in the field to wrap. Using the code below, the last field is extended to fit all available space, but when typing in the last field, the size of the grid is increased (and a horizontal scrollbar appears), rather than the cell in the text being wrapped and continuing on a new row (which is what I want to happen). Is this possible to accomplish?
<igDP:XamDataGrid AutoFit="True">
<igDP:XamDataGrid.FieldSettings>
<igDP:FieldSettings Width="Auto" AutoSizeOptions="All"/>
</igDP:XamDataGrid.FieldSettings>
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AddNewRecordLocation="OnTopFixed"
AllowAddNew="True" AutoFitMode="ExtendLastField"/>
</igDP:XamDataGrid.FieldLayoutSettings>
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:Field Name="Task" Label="Task"/>
<igDP:Field Name="Date" Label="Date"/>
<igDP:Field Name="Comment" Label="Comment">
<igDP:Field.Settings>
<igDP:FieldSettings>
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamTextEditor}">
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
Thanks for the quick response, it worked! Here's what I did:
1. Kept <igDP:FieldSettings Width="Auto" AutoSizeOptions="All"/>2. Changed autofit mode as suggested to: <igDP:FieldLayoutSettings AutoFitMode="OnlyWithVisibleStarFields"/>3. On the comment field I set the width to "*".
Works perfectly!
ExtentLastField literally just extends the last field - it will not reduce the size of the field and since you have all the fields set to size to their content (you set the FieldSettings Width to Auto) the field will be made wider as you enter more content. AutoSizing and AutoFit are essentially opposing behaviors - AutoSizing a field sizes the field to the content and AutoFit tries to adjust the size of the field's based on the available size. They can work together to an extent - the size of the field (including the calculated auto size) is used as the preferred width and then the fields are reduced/increased as needed based on the weights & autofitmode but I'm not sure that is what you are looking for.
If you take the FieldSettings Width="Auto" off you will probably get close to what you want. If the grid is made smaller though you could end up seeing a scrollbar. Perhaps what you really want is to set the AutoFitMode to OnlyWithVisibleStarFields. Then set the Width of the Comment Field to "*". Note you could still get a horizonal scrollbar if the record area is made smaller than the extent required to show the minimum width of each field.