Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Changed button text alignment after button clicked

$
0
0

Hello,

I am not sure why the button change text alignment after button clicked if the button is in a grid and there is a label and grid in StackLayout for android.

Here is a test case of the source code.

using Xamarin.Forms;

namespace ButtonTextAlignment
{
public class ContentPageGrid : ContentPage
{
public ContentPageGrid()
{
var layout = new StackLayout
{
Orientation = StackOrientation.Vertical,
Padding = 20
};

        var labelUsDollor = new Label
        {
            Text = "label",
            TextColor = Color.White,
            BackgroundColor = Color.Blue
        };
        layout.Children.Add(labelUsDollor);

        var grid = new Grid
        {
            RowSpacing = 10
        };

        var button = new Button
        {
            Text = "Click me to test",
            TextColor = Color.White,
            BackgroundColor = Color.Blue,
            WidthRequest = 400
        };

        button.Clicked += (sender, e) =>
        {
            labelUsDollor.Text = "button text change alignment";
        };

        grid.Children.Add(button, 0, 0);

        layout.Children.Add(grid);
        Content = layout;
    }
}

}

Regards
Leigh


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>