I have attached a sample app that uses the .NET9 version, Telerik MAUI 8.0.0 and RadTemplatedButton and RadComboBox.
Please make sure you use the Telerik MAUI 8.0.0 version, this version has a support for .NET 9.
Download the attached app and test on your side. Modify it so the exception can be reproduced in it. then send the app back to me. Delete bin and obj folders from the app to reduce the file size.
I was on a project with Maui 8 Telerik Maui 7.1.0. I upgraded my VS2022 to 17.12.2 and got some issue; The first one was VisualStateGroup must have unique name, adding in that tag a <VisualStateGroupList> fix the issue; After the first issue fixed, I got a second issue that is this one on that thread;
Unable to cast object of type 'Telerik.Maui.Controls.RadTemplatedButton' to type 'Microsoft.Maui.Controls.Internals.IFontElement'.
I have updated Visual Studio to 17.12.2 and added a Telerik MAUI RadTemplatedButton. Then added a style to the button and run the app on WinUI and android, I cannot reproduce issues with the project. I tested on net9. Project is attached.
@Patrick - Could you please test the attached project and let me know the results?
@Dev Presta - I am not sure how to reproduce the behavior. For sure I am missing something from the setup and I will need more details. Download the attached project and test on your side, then update it to match the setup in which the exception occurs.
@Didi, I was able to clean up my code enough to pinpoint what was causing the bug, even with your latest zipped example. With your RadCombobox, add a VisualState like this :
That's it! Changing the TargetType of DropDownButtonStyle and ClearButtonStyle to RadTemplatedButton solved the issue. And it was clearly stated in the changes note... sorry.
I have attached a sample app that uses the .NET9 version, Telerik MAUI 8.0.0 and RadTemplatedButton and RadComboBox.
Please make sure you use the Telerik MAUI 8.0.0 version, this version has a support for .NET 9.
Download the attached app and test on your side. Modify it so the exception can be reproduced in it. then send the app back to me. Delete bin and obj folders from the app to reduce the file size.
Also getting crash at startup since I upgraded to Telerik MAUI 8.0.0 using .NET8:
Unable to cast object of type 'Telerik.Maui.Controls.RadTemplatedButton' to type 'Microsoft.Maui.Controls.Internals.IFontElement'.
Can't send the project as it's huge and requires Login and server access at startup.
à Microsoft.Maui.Controls.FontElement.FontSizeDefaultValueCreator(BindableObject bindable)But I can provide the call stack if it helps:
à Microsoft.Maui.Controls.BindableObject.CreateAndAddContext(BindableProperty property)
à Microsoft.Maui.Controls.BindableObject.GetOrCreateContext(BindableProperty property)
à Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity)
à Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value, SetterSpecificity specificity)
à Microsoft.Maui.Controls.Setter.Apply(BindableObject target, SetterSpecificity specificity)
à Microsoft.Maui.Controls.Style.ApplyCore(BindableObject bindable, Style basedOn, SetterSpecificity specificity)
à Microsoft.Maui.Controls.Style.Microsoft.Maui.Controls.IStyle.Apply(BindableObject bindable, SetterSpecificity specificity)
à Microsoft.Maui.Controls.Style.ApplyCore(BindableObject bindable, Style basedOn, SetterSpecificity specificity)
à Microsoft.Maui.Controls.Style.Microsoft.Maui.Controls.IStyle.Apply(BindableObject bindable, SetterSpecificity specificity)
à Microsoft.Maui.Controls.Style.ApplyCore(BindableObject bindable, Style basedOn, SetterSpecificity specificity)
à Microsoft.Maui.Controls.Style.Microsoft.Maui.Controls.IStyle.Apply(BindableObject bindable, SetterSpecificity specificity)
à Microsoft.Maui.Controls.MergedStyle.SetStyle(IStyle implicitStyle, IList`1 classStyles, IStyle style)
à Microsoft.Maui.Controls.MergedStyle.set_Style(IStyle value)
à Microsoft.Maui.Controls.NavigableElement.<>c.<.cctor>b__22_0(BindableObject bindable, Object oldvalue, Object newvalue)
à Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent)
à Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity)
à Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value)
à Telerik.Maui.Controls.RadButtonBase.set_ActualStyle(Style value)
à Telerik.Maui.Controls.RadButtonBase.UpdateActualStyle(Style customStyle, Style implicitStyle)
à Telerik.Maui.Controls.RadButtonBase.UpdateActualStyle(Style customStyle)
à Telerik.Maui.Controls.RadButtonBase.<>c__DisplayClass100_0.<OnStyleChanged>b__0()
à Telerik.Maui.ConstructHelper.ExecOrSchedule(Action action)
à Telerik.Maui.Controls.RadButtonBase.OnStyleChanged(BindableObject bindable, Object oldValue, Object newValue)
à Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent)
à Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity)
à Microsoft.Maui.Controls.BindingExpression.ApplyCore(Object sourceObject, BindableObject target, BindableProperty property, Boolean fromTarget, SetterSpecificity specificity)
à Microsoft.Maui.Controls.BindingExpression.Apply(Object sourceObject, BindableObject target, BindableProperty property, SetterSpecificity specificity)
à Microsoft.Maui.Controls.Binding.<ApplyRelativeSourceBinding>d__27.MoveNext()
à System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
à Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.<>c__DisplayClass2_0.<Post>b__0()
I was on a project with Maui 8 Telerik Maui 7.1.0. I upgraded my VS2022 to 17.12.2 and got some issue;
The first one was VisualStateGroup must have unique name, adding in that tag a <VisualStateGroupList> fix the issue;
After the first issue fixed, I got a second issue that is this one on that thread;
Unable to cast object of type 'Telerik.Maui.Controls.RadTemplatedButton' to type 'Microsoft.Maui.Controls.Internals.IFontElement'.
Didi please :)
Hi all,
I have updated Visual Studio to 17.12.2 and added a Telerik MAUI RadTemplatedButton. Then added a style to the button and run the app on WinUI and android, I cannot reproduce issues with the project. I tested on net9. Project is attached.
@Patrick - Could you please test the attached project and let me know the results?
@Dev Presta - I am not sure how to reproduce the behavior. For sure I am missing something from the setup and I will need more details. Download the attached project and test on your side, then update it to match the setup in which the exception occurs.
<telerik:RadComboBox DisplayMemberPath="Name" IsEditable="True" IsFilteringEnabled="True" ItemsSource="{Binding Items}" NoResultsMessage="No items found." SearchTextPath="Name" SelectedItem="{Binding Item, Mode=TwoWay}"> <VisualStateManager.VisualStateGroups> <VisualStateGroupList> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal"> <VisualState.Setters> <Setter Property="DropDownButtonStyle"> <Setter.Value> <Style TargetType="telerik:RadButton"> <Setter Property="TextColor" Value="Blue" /> </Style> </Setter.Value> </Setter> </VisualState.Setters> </VisualState> <VisualState x:Name="Disabled" /> <VisualState x:Name="Focused" /> </VisualStateGroup> </VisualStateGroupList> </VisualStateManager.VisualStateGroups> </telerik:RadComboBox>
It didn't do this before I updated my VS2022 to version 17.12.2 😥
If you put the same setter in the Focused visual state, it ll compile and run, but when you focus the combobox ... boum 💥
I guess I missed a "changes note" !
That's it!
Changing the TargetType of DropDownButtonStyle and ClearButtonStyle to RadTemplatedButton solved the issue.
And it was clearly stated in the changes note... sorry.
Thank you
Hi all,
Thank you for the update and the provided code.
Yes the target type was incorrect. The new target type is RadTemplatedButton. This is addressed in the documentation: https://docs.telerik.com/devtools/maui/controls/combobox/styling
Release notes: https://www.telerik.com/support/whats-new/maui-ui/release-history/telerik-ui-for-net-maui-8-0-0-(2024-q4)
and breaking changes article: https://docs.telerik.com/devtools/maui/upgrade/breaking-changes/8-0-0#combobox
The change was due to the new theming mechanism we introduced in the controls with Telerik MAUI 8.0.0 version -> https://docs.telerik.com/devtools/maui/styling-and-themes/overview
Please review all Telerik MAUI controls you use in the application and check the breaking changes article in details: https://docs.telerik.com/devtools/maui/upgrade/breaking-changes/8-0-0