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

.EndAndExpand is aligning with end of stack above

$
0
0

I am trying to create a simple ViewCell for displaying basic file information. To the left is an icon depicting the type of file. On top is the file name and below the filename is a date (should be at start) and to the right (all the way at the end of the cell) should be the file size. What I'm seeing is the file size is aligning with the end of the filename, not the far right of the cell. The following is the code for the cell:


public class FileCell : ViewCell
    {
        public FileCell()
        {
            var image = new Image { HorizontalOptions = LayoutOptions.Start };
            image.SetBinding (Image.SourceProperty, new Binding("FileType", converter: new FileTypeToIconConverter()));
            image.WidthRequest = 16;
            image.HeightRequest = 16;

            var imageStack = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                Children = {
                    image
                }
            };

            var nameLabel = new Label {
                TextColor = Color.Black,
                Font = Font.SystemFontOfSize(NamedSize.Small),
                HorizontalOptions = LayoutOptions.StartAndExpand,
            };
            nameLabel.SetBinding(Label.TextProperty, "Name");

            var nameStack = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Children = {
                    nameLabel
                }
            };

            var dateLabel = new Label {
                TextColor = Color.FromHex("#3999D5"),
                Font = Font.SystemFontOfSize(NamedSize.Micro),
                HorizontalOptions = LayoutOptions.StartAndExpand
            };
            dateLabel.SetBinding(Label.TextProperty, "Modification");

            var sizeLabel = new Label {
                TextColor = Color.FromHex("#3999D5"),
                Font = Font.SystemFontOfSize(NamedSize.Micro, FontAttributes.Bold),
                HorizontalOptions = LayoutOptions.EndAndExpand
            };
            sizeLabel.SetBinding(Label.TextProperty, new Binding("FileSize", converter: new LongToSizeStringConverter()));

            var detailStack = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                Children = {
                    dateLabel,
                    sizeLabel
                }
            };

            var fileStack = new StackLayout {
                Orientation = StackOrientation.Vertical,
                Children = {
                    nameStack,
                    detailStack
                }
            };


            var cellStack = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                Padding = new Thickness(4,0,4,0),
                Children = {
                    imageStack,
                    fileStack
                }
            };

            View = cellStack;
        }
    }

Viewing all articles
Browse latest Browse all 58056

Trending Articles


Tabia za mabinti wa kipogoro,


Grimsby rapist jailed after attacking same woman twice on same day


HOt And Séxy Photos of Mampi


Neem Baba Extra Questions Answer Class 6 English Poorvi


Lloyds Auctioneers & Valuers Pty Limited v Benson [2025] FCA 324


Download: Chester – Baleken Basabaile (Prod. By Silva)


DT 31015


Turing Cup 2019 Qualifiers (TCQF19) - EDITORIAL


Bingie


Problem with "Removable Bootloader"



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