Draw border only at the bottom of a Xamarin Button

영훈 정 261 Reputation points

I have given the border property of the button and I want to make the border only the bottom. There seems to be a way to do it in renderer and a way to use Boxview in stacklayout. Is there a simple way to implement it?

I would appreciate it if you could provide an example.

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,000 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 16,386 Reputation points Microsoft Vendor


    The best solution to this problem is to use the BoxView as the bottom border of the button.

    It works and is concise enough.

    On Xamarin.Forms, you can make the combination of Button and BoxView into a control by using ContentView for easy reuse.

           <StackLayout Orientation="Vertical"  
               <Button Text="Click here"  
                   BorderWidth="0" />  
               <BoxView HeightRequest="1"  
                    Color="Blue" />  

    The Xamarin.Forms ContentView class is a type of Layout that contains a single child element and is typically used to create custom, reusable controls.

    Please refer to Xamarin.Forms ContentView to get more details.

    Best Regards,

    Alec Liu.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful