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

Label - text align right

$
0
0

Hi,
I´m beginner. I need set priceLabel on the right. I tried property XAlign = TextAlignment.End and nothing :-(. Thanks for answer.

`public class DishCell: ViewCell
{
public static int count = 1;

    public DishCell ()
    {
        var menuLayout = CreateMenuLayout();
        var viewLayout = new StackLayout()
        {
            Orientation = StackOrientation.Vertical,
            Children = { menuLayout }
        };

        View = viewLayout;
        count++;
    }

    static StackLayout CreateMenuLayout()
    {

        var weightLabel = new Label ()
        {
            HorizontalOptions = LayoutOptions.End,
            TextColor = Color.Black,
            Font = Font.SystemFontOfSize(14)
        };
        weightLabel.SetBinding(Label.TextProperty, "Weight");

        var dishLabel = new Label
        {
            WidthRequest = 140,
            HeightRequest = 40,
            TextColor = Color.Black,
            Font = Font.SystemFontOfSize(14)
        };
        dishLabel.SetBinding(Label.TextProperty, "Dish");

        var priceLabel = new Label()
        {
            HorizontalOptions = LayoutOptions.FillAndExpand,
            TextColor = Color.Black,
            Font = Font.BoldSystemFontOfSize(14),
            //XAlign = TextAlignment.End, //ovlivnuje zarovnani

        };

        priceLabel.SetBinding (Label.TextProperty, "Price");

        var row = new StackLayout()
        {
            Orientation = StackOrientation.Horizontal,
            Spacing = 20,
            Padding = new Thickness(10,10,10,10),
            Children = { weightLabel, dishLabel, priceLabel }
        };

        if(count % 2 == 0)
        {
            row.BackgroundColor = Color.White;
        }
        else
        {
            row.BackgroundColor = Color.FromHex("ebebeb");
        }
        return row;
    }
}`

Viewing all articles
Browse latest Browse all 77050

Trending Articles



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