djklasj dsajdkla
djklasj dsajdkla

Reputation: 81

Adding an Image to Xamarin forms

still new in Xamarin forms I am trying to add an Image.

I opened a new PCL project have a login form and a main page.

I want to add to the main page the 2 images however one the image cause the project to crash and called an unhandeled exception.

the is in the project. and add it also to the drawable libery of the Android project.

hope to get help thanks.

attaching my XAML the secound image called tmpImage is doing the issue:

<?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:local="clr-namespace:ComplexInstruction"
         x:Class="ComplexInstruction.MainPage">

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="0,1*"></RowDefinition>
        <RowDefinition Height="1*"></RowDefinition>
        <RowDefinition Height="0.1*"></RowDefinition>
        <RowDefinition Height="1*"></RowDefinition>
        <RowDefinition Height="0.1*"></RowDefinition>
        <RowDefinition Height="1*"></RowDefinition>
        <RowDefinition Height="0.1*"></RowDefinition>
        <RowDefinition Height="1*"></RowDefinition>
        <RowDefinition Height="0.1*"></RowDefinition>
        <RowDefinition Height="1*"></RowDefinition>
        <RowDefinition Height="0.1*"></RowDefinition>
        <RowDefinition Height="1*"></RowDefinition>
        <RowDefinition Height="0.1*"></RowDefinition>
    </Grid.RowDefinitions>


    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="0.1*"></ColumnDefinition>
        <ColumnDefinition Width="1*"></ColumnDefinition>
        <ColumnDefinition Width="0.1*"></ColumnDefinition>
        <ColumnDefinition Width="1*"></ColumnDefinition>
        <ColumnDefinition Width="0.1*"></ColumnDefinition>
    </Grid.ColumnDefinitions>


    <Image Aspect="Fill" Source="logo_ComplexInstructions.jpg" 
        RelativeLayout.WidthConstraint=
          "{ConstraintExpression Type=RelativeToParent, Property=Width}"
        RelativeLayout.HeightConstraint=
          "{ConstraintExpression Type=RelativeToParent, Property=Height}" Opacity="0.3" Grid.ColumnSpan="5" Grid.Row="0" Grid.RowSpan="2" />




       <Image x:Name="tmpImage" Aspect="Fill" Source="SHA_6620.jpg"
        RelativeLayout.WidthConstraint=
          "{ConstraintExpression Type=RelativeToParent, Property=Width}"
        RelativeLayout.HeightConstraint=
          "{ConstraintExpression Type=RelativeToParent, Property=Height}" 
 Grid.ColumnSpan="5" Grid.Row="3" Grid.RowSpan="8" />

</Grid>


</ContentPage>

Upvotes: 1

Views: 428

Answers (1)

Venkata Swamy Balaraju
Venkata Swamy Balaraju

Reputation: 1481

Check your image name once logo_ComplexInstructions.jpg is it correct or not

And

I thought .jpg images don't support Xamarin.Forms(I don't know exatactly)

Follow below links

https://developer.xamarin.com/api/type/System.Drawing.Imaging.ImageFormat/

Upvotes: 1

Related Questions