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

Adding C# items to Grid Layouts

$
0
0

When working with a grid layout structure in C#, like this example, adding elements to your layout doesn't work with the same syntax as others?

For Example, adding images as described here says to do this:

var beachImage = new Image { Aspect = Aspect.AspectFit };
beachImage.Source = ImageSource.FromFile("waterfront.jpg");

However, in fact I have found you must do this to compile the code:

grid.Children.Add(new Image { 
                Aspect = Aspect.AspectFit,
                Source = "logo.jpg", 
            }, 0, 1, 0, 1); // Left, Second element

Is there any documentation on how to use the basic elements in a grid layout? If not, the next issue I have hit, is how to do Label's with a title, i.e. one I can update. I would like to have this code:

grid.Children.Add(new Label { 
                x:Name="StringValue", Text="-"
            }, 1, 3);

However, neither x:Name, or Name are "Definitions in 'Xamarin.Forms.Label", how should I code that?

Thanks


Viewing all articles
Browse latest Browse all 75885

Trending Articles



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