Forum Xamarin.Forms

Problems with image

Hi, i'm begginer in Xamarin forms. I wan to do something like that:

Now I have:

Can u explain me how to stretch the image to the left side, the right side and the top side?

Best Answers


  • nnovalbosnnovalbos Member ✭✭


    What exactly do you want? Only one image in this 'row'? or put three or more images??

    For representing something like first images, you will need a CollectionView.

  • NikotiNNikotiN Member ✭✭

    I want to creat some list with 2 columns and with unlimited number of rows. But in the button should be only one image.

  • NikotiNNikotiN Member ✭✭
    edited September 2019

    Oh, it's niece : ) But I need something like button. I have created my own ImageButton(in the hope that it will solve the problem) code:
    <?xml version="1.0" encoding="UTF-8"?> <ContentView xmlns="" xmlns:x="" xmlns:d="" xmlns:mc="" mc:Ignorable="d" x:Class="TestImage.ImageButton"> <Frame CornerRadius="4" HasShadow="False" OutlineColor ="Silver" BackgroundColor="#DEDEDE" Padding="0,0,0,100"> <StackLayout Orientation="Vertical"> <Image x:Name="innerImage" VerticalOptions="StartAndExpand" HorizontalOptions="FillAndExpand" Aspect="AspectFill" BackgroundColor="Red"/> <Label x:Name="innerLabel" VerticalOptions="EndAndExpand" HorizontalOptions="CenterAndExpand"/> </StackLayout> </Frame> </ContentView>
    And my MainPage code:

    <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="" xmlns:x="" xmlns:d="" xmlns:mc="" xmlns:local="clr-namespace:TestImage" mc:Ignorable="d" x:Class="TestImage.MainPage"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <local:ImageButton VerticalOptions="Center" HorizontalOptions="Center" ButtonText="ClickMe" Source="abc.jpg" Command="{Binding MyCommand}"/> <local:ImageButton Grid.Column="1" VerticalOptions="Center" HorizontalOptions="Center" ButtonText="ClickMe" Source="archy.jpg" Command="{Binding MyCommand}"/> </Grid> </ContentPage>
    How to use CollectionView in this case?

  • nnovalbosnnovalbos Member ✭✭

    The collection items can be clicked. You don't need a button.

    FlowItemTappedCommand="{Binding ShowActorDetail}

    I imagine you want is thatwhen user press one image, the app goes to detail. or not?

  • NikotiNNikotiN Member ✭✭

    Almost so. I want that when user ckick on object(which consists of Image and text) the app goes to detail. And it will be good if the object will have border.

Sign In or Register to comment.