Hi,
I have two columns in my XamDataGrid. In on of the columns, I want to fix maxheight, and width to be Auto (which means it should adjust with column resize, have text wrap depending upon available width and also have vertical scroll bar to appear as auto. Width and height are set but wrapping doesn't work and scrolling also doesn't appear.
This is how I am trying to achieve this.
f.DataType = typeof(string); f.Settings.EditorType = typeof(XamTextEditor); f.Settings.EditorStyle = new Style(typeof(XamTextEditor)); f.Settings.EditorStyle.Setters.Add(new Setter(XamTextEditor.TextWrappingProperty, TextWrapping.Wrap)); f.Settings.EditorStyle.Setters.Add(new Setter(XamTextEditor.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Auto));
Thanks,
Imad.
Hello Imad,
Thank you for the provided feedback. Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Hi Krasimir,
I tried that solution, but for some reason not working for me. I don't know if there is anyother field that is preventing scrollbar to appear.
Here is my code with bold section where I want Scroll bar to appear. I hope you can figure out the problem.
Watiing for your response.
e.FieldLayout.Settings.AutoArrangeCells = AutoArrangeCells.LeftToRight; e.FieldLayout.Settings.DataRecordSizingMode = DataRecordSizingMode.SizedToContentAndIndividuallySizable; e.FieldLayout.DataPresenter.FieldSettings.AutoSizeOptions = FieldAutoSizeOptions.All; e.FieldLayout.DataPresenter.FieldSettings.AutoSizeScope = FieldAutoSizeScope.AllRecords; e.FieldLayout.DataPresenter.FieldLayoutSettings.AutoFitMode = AutoFitMode.ExtendLastField; e.FieldLayout.FieldSettings.AllowRecordFiltering = false; //Disable Filtering in Activity List Type objectType; //Double width = ActivityViewDg.ActualWidth; foreach (Field f in e.FieldLayout.Fields) { if (f.DataType == typeof(MyData)) { f.Visibility = Visibility.Collapsed; continue; } f.Settings.AllowEdit = false; f.Settings.LabelTextAlignment = TextAlignment.Left; objectType = f.DataType; f.DataType = typeof(string); f.Width = FieldLength.Auto; f.Settings.LabelTextWrapping = TextWrapping.Wrap; f.Settings.LabelClickAction = LabelClickAction.SortByOneFieldOnly; // update header style to include automation id Style style = new Style(typeof(LabelPresenter), Infragistics.Windows.Themes.DataPresenterGeneric.LabelPresenter); Setter setter = new Setter(); setter.Property = System.Windows.Automation.AutomationProperties.AutomationIdProperty; setter.Value = f.Name; style.Setters.Add(setter); f.Settings.LabelPresenterStyle = style; if (f.Name == "FirstField") { f.Label = ManagedResources.FindResourceString("FirstFieldKey"); f.DataType = typeof(string); f.Settings.EditorType = typeof(XamDateTimeEditor); f.Settings.EditorStyle = new Style(typeof(XamDateTimeEditor)); f.Settings.EditorStyle.Setters.Add(new Setter(XamDateTimeEditor.FormatProperty, "G")); var fsD = new FieldSortDescription { IsGroupBy = false, Field = f, FieldName = f.Name, Direction = ListSortDirection.Ascending }; e.FieldLayout.SortedFields.Add(fsD); } else { if (f.Name == "SecondField") { f.Label = ManagedResources.FindResourceString("SecondFieldKey"); f.DataType = typeof(string); f.Settings.EditorType = typeof(XamTextEditor); f.Settings.EditorStyle = new Style(typeof(XamTextEditor)); f.Settings.EditorStyle.Setters.Add(new Setter(XamTextEditor.WidthProperty, double.NaN)); f.Settings.EditorStyle.Setters.Add(new Setter(XamTextEditor.HeightProperty, (double)50)); //f.Settings.EditorStyle.Setters.Add(new Setter(XamTextEditor.MaxHeightProperty, (double)150)); f.Settings.EditorStyle.Setters.Add(new Setter(XamTextEditor.TextWrappingProperty, TextWrapping.Wrap)); f.Settings.EditorStyle.Setters.Add(new Setter(XamTextEditor.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Visible)); } } if (objectType == typeof(DateTime)) { f.Visibility = Visibility.Visible; f.Converter = _dataTranslator; f.ConverterParameter = f.Name; } }