Forum Xamarin.Forms

Creating button from code behind?

sagarsagar Member ✭✭✭

I am working on xamarin forms. Where I am creating Button from code behind. When I specify WidthRequest and HeightRequest for the button, the button text is not showing and If I remove WidthRequest and HeightRequest then the button text is showing.

Code for creating button

    Button buttonRemoveItem = new Button()
    {
        Text = "-", 
        TextColor = Color.White,
        WidthRequest = 25,
        HeightRequest = 25,
        CornerRadius = 10,
        BackgroundColor = Color.Red
    };

output

If I remove WidthRequest and HeightRequest
then my code looks like

 Button buttonRemoveItem = new Button()
    {
        Text = "-",
        TextColor = Color.White,    
        BackgroundColor = Color.Red
    };

and the output

How to resolve this?

Posts

Sign In or Register to comment.