Hey
I try to measure the size of a control, when I prefill it with values.
Therefor, I tested with the Microsoft Edit Control, which gives me the correct value, when I do the following code snipset:
Editor locEditor = new();
locEditor.Text = "TEST";
locEditor.FontFamily = this.FontFamily;
locEditor.FontSize = this.FontSize;
locEditor.ToNative(this.Handler.MauiContext);
var locSize = locEditor.Handler.GetDesiredSize(double.PositiveInfinity, double.PositiveInfinity);
locEditor = null;
RadNumericMaskedEntry locEditor = new();
locEditor.Value = "TEST";
locEditor.Handler = this.Handler;
// - Not working: var locSize = locEditor.Handler.GetDesiredSize(double.PositiveInfinity, double.PositiveInfinity);
// - Not working: var locSize = locEditor.CrossPlatformMeasure(double.PositiveInfinity, double.PositiveInfinity);
//- Not working: var locSize = locEditor.Measure(double.PositiveInfinity, double.PositiveInfinity).Request;
locEditor = null;
But when I try to use the RadNumeric, the size always returns 0
What could this be?
THX a lot in advance
Hi, Harald
It seems I cannot reproduce your case due to insufficient information.
Could you provide more information about the Handler's value, so we can get a better understanding of the issue.
Regards,
Antoan
Progress Telerik
Hey
I try to Create an Extension like this:
The idea behind it, is that the width should not be greater, than a specific text / value.namespaceTelerikMaui.ControlExtensions { publicclassISNumericInput:RadNumericMaskedEntry { public ISNumericInput() { Telerik.Maui.Handlers.RadNumericMaskedEntryHandler.ViewMapper.AppendToMapping(nameof(IViewHandler), (handler, control) => { if (control is ISNumericInput) { this.Handler = handler; this.SetControlWidth(TextMeasurement); } }); private void SetControlWidth(TypeOfTextMeasurement typeOfTextMeasurement) { RadNumericMaskedEntry locEditor = new(); locEditor.Value = 99; locEditor.Handler = this.Handler; locEditor.Unfocus(); //var locSize = locEditor.Handler.GetDesiredSize(double.PositiveInfinity, double.PositiveInfinity);//var locSize = locEditor.CrossPlatformMeasure(double.PositiveInfinity, double.PositiveInfinity);//locSize = locEditor.Measure(double.PositiveInfinity, double.PositiveInfinity).Request; tocEditor = null; this.MinimumHeightRequest = locSize.Height; this.MaximumHeightRequest = locSize.Height; this.MinimumWidthRequest = locSize.Width; this.MaximumWidthRequest = locSize.Width; this.WidthRequest = locSize.Width; this.HeightRequest = locSize.Height; } } } }