Attached properties, general extensibility and the new handlers and property mappers #305
Unanswered
GalaxiaGuy
asked this question in
Ideas
Replies: 1 comment
-
So, after watching a video by @jsuarezruiz (https://www.youtube.com/watch?v=Hfhy_zrVPbI&t=1302s), I think I've answered half of it. The borderless effect could be added after the fact as: // Assume an attached property like the following exists:
public static class BorderlessTextInput
{
public static readonly BindableProperty HasBorderProperty = BindableProperty.CreateAttached...
}
TextInputHandler.PropertyMapper[nameof(BorderlessTextInput.HasBorderProperty.PropertyName)] = MapHasBorder; Then public static void MapHasBorder(BorderlessTextInputHandler handler, IBorderlessTextInput input)
{
var hasBorder = BorderlessTextInput.GetHasBorder(input);
#if MONOANDROID
// Pretend there is an Android implementation here
#elif __IOS__
handler.TypedNativeView.SetBorderStyle(hasBorder ? UITextBorderStyle.UITextBorderStyleRoundedRect) : UITextBorderStyle.None;
#endif
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've watched most of the early MAUI videos and I've been playing around with the
main-handler
branch a bit.How will attached properties fit into the picture? I notice for example there is some
StackLayout
work, but noGrid
work.The reason I ask is, I use quite a few
Effect
s to handle platform specific behavior. Most of the time I consume them via an attached property that ultimately ends up setting a single property on a native control. That whole process is a lot of boiler plate for basically setting one property in one place (for each platform).The property mapper along with multi-targetting looks like it should make things easier. But... I could only see how to make it work with new controls.
For example, consider the Xamarin Community Toolkit
RemoveBorderEffect
: https://github.com/xamarin/XamarinCommunityToolkit/tree/main/src/CommunityToolkit/Xamarin.CommunityToolkit/Effects/RemoveBorder.It would be easy to create something like the following (assuming a
TextInputHandler
already existed):But that wouldn't be composable with others. Also, I might have a need to add a property somewhere up the inheritance chain, like
View
.Has the MAUI team considered this kind of thing at all? Do you hopefully have some secret plan that isn't apparent? Or is the perhaps some way of doing it I just haven't considered yet?
Beta Was this translation helpful? Give feedback.
All reactions