-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entry and Editor: option to disable borders and underline (focus) #7906
Comments
Instead of these two boolean properties I would prefer |
it doesn't necessarily have to be "instead of"... one thing doesn't invalidate the other |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
This is really easy to do using handlers: In CreateMauiApp add this:
Then just subclass Entry control and add the NoUnderline property and in XAML set it to True. |
Tried, works, thank you!
}` |
Any update for iOS to remove underline ? |
Here is iOS workaround.
|
I also used this method, but I have a text in the border, which cuts it off from above, how is it possible to indent the text so that it is centered on the border? |
What if I only want to change a certain entry separately? Your method is globally effective. @hartez |
@nnn149 You can make this conditional on a custom property which you can then e.g. set in XAML:
and then
|
Thank you, it works! |
Where's the windows solutions... is Maui going to be like Xamarin where it's only iOS and Android... |
would be nice to see for windows, but also i do not want blue underline to appear when entry is focused on windows |
this is how i removed entry's borders for windows
|
Thanks! This works great. Is there a way to change the colour of the caret? |
Those changes are enough to remove all visual effects from the entry: gradientDrawable.SetColor(global::Android.Graphics.Color.Transparent);
nativeView.SetBackground(gradientDrawable); I did it for all platforms, you can take a look at it: |
Is there a way to just change colors of the underline? |
Net 8 Preview 7, additionally requires: |
In my case I don't subclass Entry, Just add handler in MauiProgram and work for every Entry in my xlml pages |
Using .net 8 (8.0.0-rc.2.9373/8.0.100-rc.2), what am I doing wrong?
to MauiProgram.cs will make the entire entry transparent. Is the goto really to create my own entry, referencing different handlers that sets the "BackgrundTintList" to my desired BackgroundColor? |
I ran into this too (setting the // Either transparent or the provided background color
var backgroundTint = editor.BackgroundColor.IsDefault() ? Android.Content.Res.ColorStateList.ValueOf( Colors.Transparent.ToAndroid() )
: Android.Content.Res.ColorStateList.ValueOf( editor.BackgroundColor.ToAndroid() );
handler.PlatformView.BackgroundTintList = backgroundTint; |
I don't think this works when the Entry is highlighted. At least I dod something similar (but not 100% the same, using a Handler) and I couldn't get this approach to work properly when entry got focused (border would appear). However, the following seems to work fine on Windows when using handlers - this would be the native Windows implementation of a custom view: using MauiEntry = Microsoft.Maui.Controls.Entry;
public class NativeTextField : Grid, IDisposable
{
private readonly TextField _textField;
private readonly TextBox _textBox;
// keep a reference, so we can unhook event on Dispose
private MauiEntry _entry;
// TextField is my virtual view, a custom class that behaves a bit like an entry
public NativeTextField(TextField textField)
{
_textField = textField;
_entry = new MauiEntry();
_entry.Focused += Entry_Focused;
_textBox = (TextBox)_entry.ToPlatform(textField.Handler!.MauiContext!);
}
public void Dispose()
{
_entry.Focused -= Entry_Focused;
GC.SuppressFinalize(this);
}
// when focused: recursively look for a child border and if found, hide it
private void Entry_Focused(object? sender, Microsoft.Maui.Controls.FocusEventArgs e)
{
if (_textBox.GetFirstChildOfType<Border>() is Border border)
{
border.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed;
}
}
}
// instead of this manual implementation, could also use a CommunityToolkit WinUI Nuget package that has some Linq stuff
internal static class DependencyObjectExtensions
{
internal static DependencyObject? GetFirstChildOfType<T>(this DependencyObject textBox) where T : DependencyObject
{
var childCount = VisualTreeHelper.GetChildrenCount(textBox);
for (var i = 0; i < childCount; i++)
{
var child = VisualTreeHelper.GetChild(textBox, i);
if (child.GetType().Equals(typeof(T)))
{
return child;
}
else
{
if (GetFirstChildOfType<T>(child) is T obj)
{
return obj;
}
}
}
return null;
}
} P.S.: I think more or less the same code could be used in a Behavior, which would probably be a better idea than writing a custom |
That works nicely to remove that bottom border of the Entry control but its not removing the border of the text when I type something in the Entry. Is there a quick hack to remove that as well? I've tried changing the BackgroundColor as well as setting the Background to null as suggested in many links but that did not do the trick for the underline of the text when typing in the Entry. For context, my issue is on android, by adding Best regards. |
Have you made any further progress on this issue? |
It would be very useful to have BorderColor and BorderWisth properties on any control. I would like to set these properties similarly as the BackgroundColor. There is clearly a need for these properties. It should not be necessary that every developer has to add similar code on platform level to get this done. This should be part of MAUI. I am looking forward to these properties in the next version :-) Thanks |
This is the solutiont to just change the color!!! I spent so long looking for it :') Go to -> Platforms/Android/Resources/values/colors.xml
|
This is such a ubiquitous requirement, this absolutely be in .NET MAUI. Yep easy enough to do with handlers but there have been a couple of regressions, so making this part of .NET MAUI itself would ensure these get picked up in testing of releases. This is absolutely something nearly everyone needs and would be awesome to include. |
I was able to remove the borders, in Windows, when Entry is with focus with this line: |
Any update in 2024? |
After two years MS still chooses not to listen to developers' feedback, as always. |
Description
Would be very usefull a property called HideBorder of boolean type. The same for the underline that appears bellow the control when it has the focus.
Public API Changes
<Entry HideBorder="true" HideUnderLine="true" />
Intended Use-Case
This change is useful when you need to design a cleaner UI.
The text was updated successfully, but these errors were encountered: