|
| 1 | +--- |
| 2 | +title: "Remove under Line from entry" |
| 3 | +author: "PrashantUnity" |
| 4 | +weight: 106 |
| 5 | +date: 2025-06-19 |
| 6 | +lastmod: 2024-06-19 |
| 7 | +dateString: July 2025 |
| 8 | +description: "How to remove Entry underline from maui" |
| 9 | +#canonicalURL: "https://canonical.url/to/page" |
| 10 | +cover: |
| 11 | + image: "cover.jpg" # image path/url |
| 12 | + alt: "Download Logo" # alt text |
| 13 | + #caption: "Optical Character Recognition" display caption under cover |
| 14 | + |
| 15 | +tags: [ "NET", "codefrydev", "C sharp", "CFD","maui" , "controls","entry"] |
| 16 | +keywords: [ "NET", "codefrydev", "C sharp", "CFD","maui" , "controls"] |
| 17 | +--- |
| 18 | + |
| 19 | +## Steps Create custom class like below |
| 20 | + |
| 21 | +```cs |
| 22 | + |
| 23 | +namespace WaterReminder.CFDControl; |
| 24 | + |
| 25 | +public class CfdEntry :Entry |
| 26 | +{ |
| 27 | + protected override void OnHandlerChanged() |
| 28 | + { |
| 29 | + base.OnHandlerChanged(); |
| 30 | + |
| 31 | + SetBorderlessBackground(); |
| 32 | + } |
| 33 | + |
| 34 | + protected override void OnPropertyChanged([CallerMemberName] string propertyName = null) |
| 35 | + { |
| 36 | + base.OnPropertyChanged(propertyName); |
| 37 | + |
| 38 | + if (propertyName == nameof(BackgroundColor)) |
| 39 | + { |
| 40 | + SetBorderlessBackground(); |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + private void SetBorderlessBackground() |
| 45 | + { |
| 46 | +#if ANDROID |
| 47 | + |
| 48 | + if (Handler is IEntryHandler entryHandler) |
| 49 | + { |
| 50 | + if (BackgroundColor == null) |
| 51 | + { |
| 52 | + entryHandler.PlatformView.BackgroundTintList = |
| 53 | + Android.Content.Res.ColorStateList.ValueOf(Colors.Transparent.ToPlatform()); |
| 54 | + } |
| 55 | + else |
| 56 | + { |
| 57 | + entryHandler.PlatformView.BackgroundTintList = |
| 58 | + Android.Content.Res.ColorStateList.ValueOf(BackgroundColor.ToPlatform()); |
| 59 | + } |
| 60 | + } |
| 61 | +#endif |
| 62 | + } |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +## Step uses |
| 67 | + |
| 68 | +> Import Name Spaces. in Xaml and so on ... |
| 69 | +
|
| 70 | +```xml |
| 71 | +<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" |
| 72 | + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
| 73 | + xmlns:cfdControl="clr-namespace:WaterReminder.CFDControl"> |
| 74 | + |
| 75 | + <cfdControl:CfdEntry Placeholder="This is how you will use" /> |
| 76 | + |
| 77 | +</ContentPage> |
| 78 | +``` |
| 79 | + |
| 80 | +## Similar gor for others |
| 81 | + |
| 82 | +> Example for Picker is shown below |
| 83 | +
|
| 84 | +```cs |
| 85 | +public class CfdPicker : Picker |
| 86 | +{ |
| 87 | + protected override void OnHandlerChanged() |
| 88 | + { |
| 89 | + base.OnHandlerChanged(); |
| 90 | + |
| 91 | + SetBorderlessBackground(); |
| 92 | + } |
| 93 | + |
| 94 | + protected override void OnPropertyChanged([CallerMemberName] string propertyName = null) |
| 95 | + { |
| 96 | + base.OnPropertyChanged(propertyName); |
| 97 | + |
| 98 | + if (propertyName == nameof(BackgroundColor)) |
| 99 | + { |
| 100 | + SetBorderlessBackground(); |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + private void SetBorderlessBackground() |
| 105 | + { |
| 106 | +#if ANDROID |
| 107 | + |
| 108 | + if (Handler is IPickerHandler pickerHandler) |
| 109 | + { |
| 110 | + if (BackgroundColor == null) |
| 111 | + { |
| 112 | + pickerHandler.PlatformView.BackgroundTintList = |
| 113 | + Android.Content.Res.ColorStateList.ValueOf(Colors.Transparent.ToPlatform()); |
| 114 | + } |
| 115 | + else |
| 116 | + { |
| 117 | + pickerHandler.PlatformView.BackgroundTintList = |
| 118 | + Android.Content.Res.ColorStateList.ValueOf(BackgroundColor.ToPlatform()); |
| 119 | + } |
| 120 | + } |
| 121 | +#endif |
| 122 | + } |
| 123 | +} |
| 124 | +``` |
0 commit comments