{"record":{"id":"a080604a43347629","repo":"AvaloniaUI/Avalonia","slug":"maxtextheight-property-value-must-be-greater-tha","errorCode":null,"errorMessage":"'MaxTextHeight' property value must be greater than zero.","messagePattern":"'MaxTextHeight' property value must be greater than zero\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Media/FormattedText.cs","lineNumber":1146,"sourceCode":"        /// <returns>The copy of max text width array</returns>\n        public double[] GetMaxTextWidths()\n        {\n            return _maxTextWidths != null ? (double[])_maxTextWidths.Clone() : Array.Empty<double>();\n        }\n\n        /// <summary>\n        /// Sets the maximum length of a column of text.\n        /// The last line of text displayed is the last whole line that will fit within this limit,\n        /// or the nth line as specified by MaxLineCount, whichever occurs first.\n        /// Use the Trimming property to control how the omission of text is indicated.\n        /// </summary>\n        public double MaxTextHeight\n        {\n            set\n            {\n                if (value <= 0)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(value), $\"'{nameof(MaxTextHeight)}' property value must be greater than zero.\");\n                }\n\n                if (double.IsNaN(value))\n                {\n                    throw new ArgumentOutOfRangeException(nameof(value), $\"'{nameof(MaxTextHeight)}' property value cannot be NaN.\");\n                }\n\n                _maxTextHeight = value;\n\n                InvalidateMetrics();\n            }\n            get\n            {\n                return _maxTextHeight;\n            }\n        }\n\n        /// <summary>","sourceCodeStart":1128,"sourceCodeEnd":1164,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Media/FormattedText.cs#L1128-L1164","documentation":"FormattedText.MaxTextHeight setter rejects non-positive values because layout divides/clamps against the column height and needs a positive bound. Unlike MaxTextWidth (where 0 means unbounded), MaxTextHeight treats 0 as invalid.","triggerScenarios":"Binding MaxTextHeight to an unmeasured container; passing 0 from an uninitialized field; computing from a padding subtraction that yields 0 or negative on small containers.","commonSituations":"A 'show more text' UI where the collapsed height is set to 0 incorrectly; binding to ActualHeight during initial layout (still 0); using a default double value of 0.","solutions":["Use a sentinel meaning 'no limit' (e.g. double.PositiveInfinity) elsewhere and only assign MaxTextHeight when a positive bound is genuinely wanted.","Defer the assignment until the container has a measured positive height.","Coerce to a minimum positive value (e.g. line height) before setting.","Initialize the backing field to a sensible positive default."],"exampleFix":"// before\nft.MaxTextHeight = container.ActualHeight; // 0 during first layout pass\n\n// after\ndouble h = container.ActualHeight;\nft.MaxTextHeight = h > 0 ? h : double.PositiveInfinity; // or omit the limit","handlingStrategy":"validation","validationCode":"double h = double.IsFinite(value) && value > 0 ? value : double.PositiveInfinity;\nif (double.IsFinite(h)) ft.MaxTextHeight = h;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use double.PositiveInfinity or omit the limit rather than passing 0.","Defer assignment until layout has a positive measured height.","Initialize backing fields to a sensible positive default."],"tags":["text","formatted-text","layout","height","argument-validation"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}