question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Proposal] RemoveBorderEffect

See original GitHub issue

RemoveBorderEffect

  • Proposed
  • Prototype: Not Started
  • Implementation: Not Started
    • iOS Support
    • Android Support
    • macOS Support
    • Windows Support
  • Unit Tests: Not Started
  • Sample: Not Started
  • Documentation: Not Started

Summary

Removes a border from a VisualElement

Detailed Design

RemoveBorderEffect.shared.cs

public class RemoveBorderEffect : RoutingEffect
{
}

RemoveBorderEffect.Android.cs

public class RemoveBorderEffect : PlatformEffect
{
  Drawable? originalBackground;

  protected override void OnAttached()
  {
	originalBackground = Control.Background;

	var shape = new ShapeDrawable(new RectShape());
	if (shape.Paint != null)
	{
		shape.Paint.Color = global::Android.Graphics.Color.Transparent;
		shape.Paint.StrokeWidth = 0;
		shape.Paint.SetStyle(Paint.Style.Stroke);
	}

	Control.Background = shape;
  }

  protected override void OnDetached() => Control.Background = originalBackground;
}

RemoveBorderEffect.iOS.cs

public class RemoveBorderEffect : PlatformEffect
{
  UITextBorderStyle? oldBorderStyle;
  
  UITextField? TextField => Control as UITextField;
  
  protected override void OnAttached()
  {
	oldBorderStyle = TextField?.BorderStyle;
	SetBorderStyle(UITextBorderStyle.None);
  }
  
  protected override void OnDetached() => SetBorderStyle(oldBorderStyle);

  void SetBorderStyle(UITextBorderStyle? borderStyle)
  {
	if (TextField != null && borderStyle.HasValue)
		TextField.BorderStyle = borderStyle.Value;
  }
}

RemoveBorderEffect.uwp.cs

public class RemoveBorderEffect : PlatformEffect
{
  Thickness oldBorderThickness;
  
  protected override void OnAttached()
  {
	if (Control is Control uwpControl)
	{
		oldBorderThickness = uwpControl.BorderThickness;
		uwpControl.BorderThickness = new Thickness(0.0);
	}
  }
  
  protected override void OnDetached()
  {
	if (Control is Control uwpControl)
	{
		uwpControl.BorderThickness = oldBorderThickness;
	}
  }
}

Usage Syntax

XAML Usage

<Label
    <Label.Effects>
        <local: RemoveBorderEffect/>
    </Label.Effects>
</Label>

C# Usage

var label = new Label();
label.Effects.Add(new RemoveBorderEffect());

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
pictoscommented, Nov 11, 2022

In order to remove the Entry border you can do the following for android and ios:

EntryHandler.Mapper.AppendToMapping("Background", (handler, view) =>
{
#if ANDROID
	var shape = new Android.Graphics.Drawables.ShapeDrawable(new Android.Graphics.Drawables.Shapes.RectShape());

	if (shape.Paint is not null)
	{
		shape.Paint.Color = Android.Graphics.Color.Transparent;
		shape.Paint.StrokeWidth = 0;
		shape.Paint.SetStyle(Android.Graphics.Paint.Style.Stroke);
	}
	handler.PlatformView.Background = shape;
#elif IOS || MACCATALYST
	handler.PlatformView.BorderStyle = UIKit.UITextBorderStyle.None;
#endif
});

For windows just add these resources on your Platform/Windows/App.xaml

<maui:MauiWinUIApplication.Resources>
	<Thickness x:Key="TextControlBorderThemeThickness">0</Thickness>
	<Thickness x:Key="TextControlBorderThemeThicknessFocused">0</Thickness>
</maui:MauiWinUIApplication.Resources>

With that I still believe it’s a very simple code to keep here.

1reaction
pictoscommented, Nov 7, 2022

@KSemenenko you can open an issue on Maui repo itself, since it’s related to a control… Maybe it’s something that you can solve already using an style.

Read more comments on GitHub >

github_iconTop Results From Across the Web

New Feature Proposals
NET MAUI developer easier - New Feature Proposals · CommunityToolkit/Maui. ... [Proposal] `ValueTask Async Command ... [Proposal] RemoveBorderEffect.
Read more >
RemoveBorderEffect Class (Xamarin.CommunityToolkit. ...
RemoveBorderEffect Class · In this article · Definition · Constructors · Applies to · Additional resources.
Read more >
Features List · xamarin/XamarinCommunityToolkit Wiki
RemoveBorderEffect, Removes a border from a VisualElement, TBD. SafeAreaEffect, Indicates whether or not that element should take current ...
Read more >
Multistrategy Self-Organizing Map Learning for ...
The proposed method was used to remove border effect in SOM, but the limitation was slower in computation times. Furthermore, Kihato et al....
Read more >
Deinterlacing, Scaling, Processing: Special OSSC Review ...
All of these offer fantastic results, but all of them are very ... optimized output timings (to remove border effect on certain TVs)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found