CommunityToolkit / Maui

The .NET MAUI Community Toolkit is a community-created library that contains .NET MAUI Extensions, Advanced UI/UX Controls, and Behaviors to help make your life as a .NET MAUI developer easier
https://learn.microsoft.com/dotnet/communitytoolkit/maui
MIT License
2.09k stars 337 forks source link

[BUG]Custom control with email validator doesn't change border #1874

Closed eduardoagr closed 3 weeks ago

eduardoagr commented 3 weeks ago

Is there an existing issue for this?

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

I have a custom control, that shows the textbox with a border and an hint

Expected Behavior

I want to change the border color, when the email is not valid, and change the border color to green

Steps To Reproduce

  1. Open the Solution
  2. input a bad email address (It doesn't change color)

Link to public reproduction project repository

https://github.com/eduardoagr/CustomEntry

Environment

- .NET MAUI CommunityToolkit:
- OS: Edition   Windows 11 Education Version 23H2
- .NET MAUI: 8.0.21

Anything else?

No response

brminnick commented 3 weeks ago

It looks like this is a question on how you can update your app to correctly use EmailValidaitonBehavior with your custom entry.

Your attached sample has a few problems:

  1. It crashes on startup:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.TypeInitializationException: The type initializer for 'CustomEntry.Controls.CustomEntry' threw an exception.
  1. You are attaching the EmailValidationBehavior to controls:CustomEntry whose text never changes because the Entry in your XAML does not have a Binding to ViewModel.Entry

I am converting this to a discussion because I don't see a bug here with EmailValidaitonBehavior, rather an incorrect implementation.

dotnet-policy-service[bot] commented 3 weeks ago

Hi @eduardoagr. We have added the "needs reproduction" label to this issue, which indicates that we cannot take further action. This issue will be closed automatically in 5 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.