Background image

2 posts, 1 answers
  1. Stavros
    Stavros avatar
    18 posts
    Member since:
    Oct 2017

    Posted 29 Oct 2018 Link to this post

    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);


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

    it doesn't work. 

  2. Answer
    Lance | Team Lead - US DevTools Support
    Lance | Team Lead - US DevTools Support avatar
    1070 posts

    Posted 29 Oct 2018 Link to this post

    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?

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

    protected override void 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).

    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
Back to Top