Closed SalvatoreDiFede closed 6 months ago
Well I don't know if there is a direct way to do this, but what you could do is recreate your version of this Validator the original code which can be found here: https://github.com/CommunityToolkit/Maui/blob/main/src/CommunityToolkit.Maui/Behaviors/Validators/TextValidationBehavior.shared.cs
And, you could add some code to this behaviour that gets the Entry reference through FindByName
and then apply the behaviour accordingly, Name for the View is here: https://github.com/FreakyAli/Maui.FreakyControls/blob/0de0401657edb3247c0e226a60ab577c05a5c504/MAUI.FreakyControls/MAUI.FreakyControls/Shared/FreakyTextInputLayout/FreakyTextInputLayout.xaml#L24
So in the OnAttach method you would do something like this:
public class TextValidationBehavior : Behavior<FreakyTextInputLayout>
{
protected override void OnAttachedTo(FreakyTextInputLayout bindable)
{
base.OnAttachedTo(bindable);
var entry = bindable.FindByName("EntryField");
}
}
There is also a BehvaviorBase implementation in FreakyControls that you can use to get the AssociatedObject without creating a reference for it manually: https://github.com/FreakyAli/Maui.FreakyControls/blob/master/MAUI.FreakyControls/MAUI.FreakyControls/Shared/Behaviors/BehaviorBase.cs
Hope this makes sense,
Feel free to ask any questions that come to mind...
Oh, thanks, i'll try!
BTW my original idea was to set EntryField public and bindable and to add something like this:
[TypeConverter(typeof(Field))] public Field EntryField { get { return (Field)GetValue(EntryFieldProperty); } set { SetValue(EntryFieldProperty, value); } }
I apologize but my knowledge of this is very limited :(
It's fine, do let me know if you face any issues, and I will try to help you out, how much ever i can!
@SalvatoreDiFede Did you get anywhere with this?
@SalvatoreDiFede I will close this assuming you worked things out, you can always reopen this or create a new one if needed!
Thank'u @FreakyAli . Had no way nor time to implement this lately. Sorry
Hi there, it would be nice to implements behaviors for Entry from communitytoolkit
For example: https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/behaviors/text-validation-behavior
Problem: FreakyTextInputLayout derives from ContentView and FreakyEntry is not binded, nor public.
Any idea on how to solve or implement this?
Thank'u!