AbsoluteLayout. Seems simple but oh so hard to implement :-(

Hi Guys,
I have a simple listview with some text and an image.... but cant seem to make AbsoluteLayout work for the image(s). [i need it/them vertically centered within each cell and right aligned].
Is there some sort of magic trick to make this work (see image).
Thanks :-)

    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <StackLayout Orientation="Vertical" Padding="10,10,15,10">
                    <Label Text="{Binding Name}" FontSize="18" FontAttributes="Bold" TextColor="Black"/>
                    <Label Text="{Binding Path}" FontSize="9"/>
                    <AbsoluteLayout BackgroundColor="Maroon" AbsoluteLayout.LayoutBounds="1,0,.5,.1" AbsoluteLayout.LayoutFlags="All">
                            <Image Source="{Binding Image}" />
                    </AbsoluteLayout>
                </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>![]()

Best Answer

Answers

  • Oh so close :-)

    <ViewCell>
        <StackLayout Orientation="Vertical" Padding="10,10,15,10">
            <Grid Padding="0" RowSpacing="0" ColumnSpacing="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="20" />
                </Grid.ColumnDefinitions>
                <Label Text="{Binding Name}" FontSize="18" FontAttributes="Bold" TextColor="Black" Grid.Column="0"/>
                <Image Source="{Binding Image}" HorizontalOptions="End" Grid.Column="1" WidthRequest="20" MinimumWidthRequest="20"/>    
            </Grid>
        </StackLayout>
    </ViewCell>
    
Sign In or Register to comment.