Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Referencing XAML element from C# with x:Name

$
0
0

Hi guys,

in the file foo.xaml (the XAML file) I have something like this:

<Image x:Name="pippo"/>

in the file foo.xaml.cs (the C# file) I tried to reference the element in this way:

Image im = (Image)pippo;

I was sure that I'd get it right cause pippo's an image in the xaml file, but unfortunatly it gives an System.InvalidCastException.

Why is that?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>