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

Answers

  • nnovalbosnnovalbos Member ✭✭

    Hi,

    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 22

    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="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 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="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 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.