Declined
Last Updated: 18 Nov 2022 15:28 by ADMIN
Josh
Created on: 17 Nov 2022 00:17
Category: UI for .NET MAUI
Type: Feature Request
1
Feature Request: All Rad controls [that display text] should implement IFontElement

Hello,

TL;DR version - I request that the IFontElement interface (from Microsoft.Maui.Controls.Internals) be implemented on all Rad type controls that display text.

Detailed Version:

The CommunityToolkit.Maui.Markup nuget package provides some really nice extension methods that allow quick and easy configuring of controls without verbosity. When using the toolkit along side Telerik UI every extension I have tried works really well except for .Font(). On all standard MAUI controls you can just call the .Font() extension method and don't need to create a Style and apply it to an underlying property just to set a font size - you just set the size with .Font() as shown below. The below example code snippet shows the normal use of the toolkit on a standard MAUI Label and a RadTimeSpanPicker from the Telerik UI MAUI package.

The above example yields the following error, as does calling .Font() on pretty much every other Radxxxx control. Telerik UI controls seem to work really well with all the other extension methods I have tried from the toolkit except the .Font() extension method.

The type 'Telerik.Maui.Controls.RadTimeSpanPicker' cannot be used as type parameter 'TFontElement' in the generic type or method 'ElementExtensions.Font<TFontElement>(TFontElement, string?, double?, bool?, bool?)'. There is no implicit reference conversion from 'Telerik.Maui.Controls.RadTimeSpanPicker' to 'Microsoft.Maui.Controls.Internals.IFontElement'.

It would seem that implementing IFontElement would solve this.

This would be a nice feature and very helpful to anybody using the toolkit with Telerik controls because they could be used the same way as standard MAUI controls.

I looked under the hood a little bit and I believe the interface could/should be implemented on something like RadContentView which seems to be where most interfaces are inherited/implemented, and controls like RadTimePicker inherit from parent controls that eventually inherit from RadContentView.

1 comment
ADMIN
Antoan
Posted on: 18 Nov 2022 15:28

Hello Josh,

After a discussion with the developers I have updated the status of this feature request as declined. The RadNumericInput, RadTimePicker, and RadTimeSpanPicker, etc are not designed to support such implementation, if such is added the architecture of the controls needs to be refactored as a whole

What I can offer as a solution is to use an extension method for the Picker which changes the font style of all labels which are contained in said picker. Keep in mind that the new styling needs to be applied to the DisplayLabelStyle property, etc. otherwise you won't notice any change.

The implementation looks as follow for the RadTemplatedPicker: 

public static void LabelStyle(this RadTemplatedPicker picker, double fontSize)
        {
            Style labelStyle = new Style(typeof(Label));
            labelStyle.Setters.Add(new Setter { Property = Label.FontSizeProperty, Value = fontSize });

            picker.DisplayLabelStyle = labelStyle;
            picker.PlaceholderLabelStyle = labelStyle;
        }

In addition you can check the following resources regarding Picker styling:

I hope this brings some clarity on the case.

Regards,
Antoan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.