[Proposal] Add Overloaded Constructor to Style<T>
that Accepts Microsoft.Maui.Controls.Style
#274
Labels
approved
champion
A member of the .NET MAUI Toolkit core team has chosen to champion this feature
help wanted
This proposal has been approved and is ready to be implemented
needs discussion
The team will aim to discuss this at the next monthly standup
proposal
A fully fleshed out proposal describing a new feature in syntactic and semantic detail
Projects
Feature name
Add Overloaded Constructor to
Style<T>
that AcceptsMicrosoft.Maui.Controls.Style
Link to discussion
dotnet/maui#19725 (comment)
Progress tracker
Summary
This Proposal adds another constructor to
Style<T>
that accepts.Microsoft.Maui.Controls.Style
.Motivation
The community has noted that it would be beneficial to easily convert
Microsoft.Maui.Controls.Style
toCommunityToolkit.Maui.Markup.Style<T>
.Detailed Design
Usage Syntax
Drawbacks
I cannot think of any drawbacks at this time.
Alternatives
The current alternative to converting a
Microsoft.Maui.Controls.Style
toStyle<T>
is complicated and requires a for loop to move all of the BindableProperties fromStyle
toStyle<T>
.Unresolved Questions
Is there a valid use case where the type for
MauiStyle.TargetType
wouldn't match the type used for Style?If not, I think it's best to throw an exception when
!mauiStyle.TargetType.IsAssignableTo(typeof(T))
.E.g. The following code throws an
InvalidArgumentException
:The text was updated successfully, but these errors were encountered: