How to set ImageSource as Xamarin.Forms.Button?

后端 未结 6 1386
野性不改
野性不改 2021-01-04 11:28

I am trying add a background image using the image property in button. The issue I\'m facing is that i can\'t set StreamImageSource as button background. I encountered the e

6条回答
  •  囚心锁ツ
    2021-01-04 12:22

    Here is what I tried:

    Button refreshBut = new Button
            {
                Image = (FileImageSource)
                (ImageSource.FromFile("refreshBut.png"))
    
            };
    

    While it compiles I then get an unhandled null reference exception with the description: Object reference not set to an instance of an object. I am not sure if this will help anyone else try to solve this but I am at the same wall.

提交回复
热议问题