Hi. I'm adding an UnboundField at the runtime by using this code:
UnboundField field = new UnboundField();field.Name = "Field";field.Label = "Field";field.BindingPath = new PropertyPath("Property");field.Settings.CellValuePresenterStyle = TryFindResource("FieldStyle") as Style; field.Settings.AutoSizeOptions = FieldAutoSizeOptions.Label;field.Settings.AutoSizeScope = FieldAutoSizeScope.AllRecords;
Field is added and successfully binded to the data, but it's not automatically resized. Am I doing something wrong?
The autosize settings are only used when using autosizing which means either when the Width property of the Field is set to InitialAuto/Auto or you double click the right edge. Note the settings you have don't really make sense to me. You have it set up such that the field will be autosized based on the width of the Label only (AutoSizeOptions is a flagged enum that by default will include everything) but then you have set the AutoSizeScope to AllRecords (which means the cells of all records and not just those in view should be considered) but since there are no cell related flags in the AutoSizeOptions that won't really mean anything because you only have it set to size to the label. Assuming you want it to consider the cells then you probably don't need to set the AutoSizeOptions. So just to summarize:
Andrew, thank you very much for clarification - now it works as I expected. I've got one more question: is there property for Field that prevent field to be moved (I need some kind if field fixing, but they still should be scrollable).
There is no property to prevent a single field from being moved since moving other fields would implicitly move the position of a given field; you can only disable moving for the entire field layout. If you mean that you have a field that you want to fix and keep fixed (i.e.not allow the end user to unfix it) then I believe you can set the FixedLocation of the Field to where you want it fixed and then set its FieldSettings->AllowFixing to No.