0

Having trouble getting this to work - I must be missing something:

signaturePad2.BackgroundImageView = new ImageView(Context)
{
   Id = GenerateId(this),
   LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent)
};

signaturePad2.AddView(BackgroundImageView);
signaturePad2.BackgroundImage = MyGlobals.FileNameOfPhotoTaken;
Michał Żołnieruk
  • 2,095
  • 12
  • 20

1 Answers1

1

BackgroundImage is of type ImageSource

padView.BackgroundImage = ImageSource.FromUri(new Uri(
    "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f2/Xamarin-logo.svg/220px-Xamarin-logo.svg.png"));
Jason
  • 86,222
  • 15
  • 131
  • 146
  • Tried this (deleted everything after it), but get an error: Unhandled Exception: System.InvalidCastException: Specified cast is not valid. occurred – PizzaBoatJim Apr 10 '18 at 02:37
  • I did change "padView" to "signaturePad2" which is what I called the signature pad on my XAML. Any ideas what is wrong? – PizzaBoatJim Apr 10 '18 at 02:38
  • This is the line in "SignaturePadView.cs" that had the problem: propertyChanged: (bindable, oldValue, newValue) => ((SignaturePadView)bindable).BackgroundImageView.Source = (ImageSource)newValue); – PizzaBoatJim Apr 10 '18 at 02:39
  • Do I need to have the file "SignaturePadView.cs" in my project? Maybe that is the problem. – PizzaBoatJim Apr 10 '18 at 02:53
  • No. Are you sure you're using the correct (and latest) package for signatures? Are you doing this code in your shared project or in your platform project? – Jason Apr 10 '18 at 02:59
  • I am pretty sure I have tge latest package. At one time I created a "SignaturePadView.cs" file and added all the methods fron the GRIT page. Should I delete that? Right now all the files are in the shared project. Is that where these signaturepad files should be? – PizzaBoatJim Apr 10 '18 at 03:29
  • Ah - I see I need to delete that .cs file. I'll do that tomorrow - i have a real early start tomorrow. Thank you – PizzaBoatJim Apr 10 '18 at 03:31