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

Showing Android GridView using PageRenderer

$
0
0

Hi!
I try to show GridView in the ContentPage, using such way:
`
public class Page1Render : Xamarin.Forms.Platform.Android.PageRenderer
{
public Page1Render()
{
}

    protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
    {
        base.OnElementChanged(e);

        GridView grd = new GridView(this.Context);
        grd.SetColumnWidth(100);
        grd.StretchMode = StretchMode.StretchColumnWidth;
        grd.SetGravity(GravityFlags.Center);
        grd.Adapter = new ImageAdapter(this.Context);
        grd.ItemClick += (sender, args) => Toast.MakeText(this.Context, args.Position.ToString(), ToastLength.Short).Show();

        this.AddView(grd, ViewGroup.LayoutParams.FillParent);
    }
}

, but I dont see GridView on the screen. Is it right way to add gridview on the ContentPage?


Viewing all articles
Browse latest Browse all 75885

Trending Articles