This is a migrated thread and some comments may be shown as answers.

Background image

1 Answer 1597 Views
Button
This is a migrated thread and some comments may be shown as answers.
Stavros
Top achievements
Rank 1
Stavros asked on 29 Oct 2018, 11:01 AM
The background image is working only if the image is located in each of the application projects (Resources folder in iOS, Resources/Drawable folder in Android, and application root in UWP; each with the appropriate build action set).
When I am using an image from a file like
BackgroundImage = ImageSource.FromFile(image.Path);

or 

BackgroundImage = ImageSource.FromUri(new Uri (uri));

it doesn't work. 

1 Answer, 1 is accepted

Sort by
0
Accepted
Lance | Manager Technical Support
Telerik team
answered on 29 Oct 2018, 01:35 PM
Hello Stavros,

The BackgroundImage property works like the default Xamarin.Forms Image control. You can use an ImageSource object, regardless of how the ImageSource object is created.

Can you double check that the image is loading by testing the source with an Image control next to the button?

<StackLayout>
    <Image x:Name="MyImage" HeightRequest="100" WidthRequest="200" />
    <input:RadButton x:Name="MyButton" HeightRequest="100" WidthRequest="200" />
</StackLayout>

protected override void OnAppearing()
{
    base.OnAppearing();
 
    var imgSource = ImageSource.FromFile("filePath");
 
    MyImage.Source = imgSource;
    MyButton.BackgroundImage = imgSource;
}

If you see the Image get populated but not the button, please send me a reproducible project so I can file a bug report (I cannot reproduce what you're seeing).

If the Image doesn't show, I recommend either checking the image.Path property (make sure it's populated), or check that the image file is where it's supposed to be (see Working with Images article from Microsoft).

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Button
Asked by
Stavros
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Share this question
or