TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Pratik Shirse
1.2k
581
65k
System.TypeInitializationException: GridView
Jun 29 2019 5:44 AM
we are create new New Project in vs2019
xamarin.forms with Master Details(android & Ios) also creating the grid view but when i run the project and click on the GridListPage we getting the error
my code is below kindly suggest us where is the wrong
GridListPage.xaml
<?xml version=
"1.0"
encoding=
"utf-8"
?>
<ContentPage xmlns=
"http://xamarin.com/schemas/2014/forms"
xmlns:x=
"http://schemas.microsoft.com/winfx/2009/xaml"
x:Class=
"CollectionViewSample.Views.GridListPage"
xmlns:vm=
"clr-namespace:CollectionViewSample.ViewModels"
Title=
"{Binding Title}"
>
<ContentPage.BindingContext>
<vm:GridListViewModel />
</ContentPage.BindingContext>
<ContentPage.Content>
<StackLayout>
<CollectionView x:Name=
"CV"
ItemsSource=
"{Binding DataSource}"
VerticalOptions=
"Center"
HorizontalOptions=
"Center"
Margin=
"10,0,10,0"
>
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation=
"Vertical"
Span=
"2"
/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType=
"vm:GridListViewModel"
>
<Frame BorderColor=
"LightGray"
CornerRadius=
"3"
HasShadow=
"False"
>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=
"Auto"
/>
<ColumnDefinition Width=
"100"
/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height=
"Auto"
/>
<RowDefinition Height=
"*"
/>
</Grid.RowDefinitions>
<Image Grid.Column=
"0"
Source=
"person"
Aspect=
"Fill"
/>
<StackLayout Grid.Column=
"1"
>
<Label Text=
"{Binding}"
HorizontalOptions=
"EndAndExpand"
VerticalOptions=
"CenterAndExpand"
/>
</StackLayout>
</Grid>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
GridListViewModel.cs
using
System;
using
System.Collections.Generic;
using
System.Text;
namespace
CollectionViewSample.ViewModels
{
public
class
GridListViewModel : BaseViewModel
{
public
GridListViewModel()
{
Title =
"Grid List View"
;
}
}
}
GridListPage.xaml.cs
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
Xamarin.Forms;
using
Xamarin.Forms.Xaml;
namespace
CollectionViewSample.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public
partial
class
GridListPage : ContentPage
{
public
List<
string
> DataSource {
get
; }
public
GridListPage()
{
InitializeComponent();
DataSource =
new
List<
string
>
{
"Alan"
,
"Betty"
,
"Charles"
,
"David"
,
"Edward"
,
"Francis"
,
"Gary"
,
"Helen"
,
"Ivan"
,
"Joel"
,
"Kelly"
,
"Larry"
,
"Mary"
,
"Nancy"
,
"Olivia"
,
"Peter"
,
"Quincy"
,
"Robert"
,
"Stephen"
,
"Timothy"
,
"Ursula"
,
"Vincent"
,
"William"
,
"Xavier"
,
"Yvonne"
,
"Zack"
};
CV.BindingContext =
this
;
}
}
}
Reply
Answers (
3
)
Paytm Integration in Xamarin.android
Hybrid mobile application development