I am modifying my app on the widows side
I have created a handler for SearchBar and Entry
public class BorderlessEntry : Entry {
}
public class BorderlessSearchBar : SearchBar {
}
I put this in App
Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping("BorderlessEntry", (handler, view) => {
if (view is BorderlessEntry) {
#if ANDROID
handler.PlatformView.Background = null;
handler.PlatformView.SetBackgroundColor(Android.Graphics.Color.Transparent);
#elif WINDOWS
handler.PlatformView.BorderThickness = new Microsoft.UI.Xaml.Thickness(0);
#elif IOS || MACCATALYST
handler.PlatformView.BackgroundColor = UIKit.UIColor.Clear;
handler.PlatformView.Layer.BorderWidth = 0;
handler.PlatformView.BorderStyle = UIKit.UITextBorderStyle.None;
#endif
}
});
Microsoft.Maui.Handlers.SearchBarHandler.Mapper.AppendToMapping("BorderlessSearchBar", (handler, view) => {
if (view is BorderlessSearchBar) {
#if ANDROID
handler.PlatformView.Background = null;
handler.PlatformView.SetBackgroundColor(Android.Graphics.Color.Transparent);
#elif WINDOWS
handler.PlatformView.BorderThickness = new Microsoft.UI.Xaml.Thickness(0);
#elif IOS || MACCATALYST
handler.PlatformView.BackgroundColor = UIKit.UIColor.Clear;
handler.PlatformView.Layer.BorderWidth = 0;
handler.PlatformView.BorderStyle = UIKit.UITextBorderStyle.None;
#endif
}
});
But I also had to modify the Windows App, and also included some modifications
<maui:MauiWinUIApplication
x:Class="DemyAI.WinUI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:DemyAI.WinUI"
xmlns:maui="using:Microsoft.Maui">
<maui:MauiWinUIApplication.Resources>
<Thickness x:Key="TextControlBorderThemeThickness">0</Thickness>
<Thickness x:Key="TextControlBorderThemeThicknessFocused">0</Thickness>
<DataTemplate x:Key="MauiAppTitleBarTemplate">
<Grid>
<Border
VerticalAlignment="Stretch"
Background="#e8e8e8"
Canvas.ZIndex="1">
<TextBlock
Margin="10,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontWeight="Bold"
Text="Demy IA" />
</Border>
</Grid>
</DataTemplate>
</maui:MauiWinUIApplication.Resources>
</maui:MauiWinUIApplication>
I know that windows works fine, but I want to test this on Android
I also created a behavior for cursors
I only Implamented this on MacOS and Windows
#if MACCATALYST
using DemyAI.Platforms.MacCatalyst;
#elif WINDOWS
using DemyAI.Platforms.Windows;
#endif
namespace DemyAI.Behaviors {
public class CursorBehavior {
public static readonly BindableProperty CursorProperty = BindableProperty.CreateAttached("Cursor", typeof(CursorIcon), typeof(CursorBehavior), CursorIcon.Arrow, propertyChanged: CursorChanged);
private static void CursorChanged(BindableObject bindable, object oldvalue, object newvalue) {
if (bindable is VisualElement visualElement) {
visualElement.SetCustomCursor((CursorIcon)newvalue, Application.Current?.MainPage?.Handler?.MauiContext!);
}
}
public static CursorIcon GetCursor(BindableObject view) => (CursorIcon)view.GetValue(CursorProperty);
public static void SetCursor(BindableObject view, CursorIcon value) => view.SetValue(CursorProperty, value);
}
}
So if I want to run this is android I will git an error
I am also using this behavior in XAML
So I know I get this errors

If Iam using the cursor behavior here
<Label
Grid.RowSpan="2"
Grid.Column="1"
behaviors:CursorBehavior.Cursor="Hand"
If I use android, it will ignore this line?
I dont understand the errors
because
handler.PlatformView.BorderStyle = UIKit.UITextBorderStyle.None;
is part of my if
#elif IOS || MACCATALYST
handler.PlatformView.BackgroundColor = UIKit.UIColor.Clear;
handler.PlatformView.Layer.BorderWidth = 0;
handler.PlatformView.BorderStyle = UIKit.UITextBorderStyle.None;
#endif