Skip to content

Commit df7ae5d

Browse files
committed
Updated the README.md file.
1 parent 069ed40 commit df7ae5d

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

README.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,128 @@
11
# How to bind data from the datatable to listview in Xamarin.Forms
22
This example demonstrates how to bind the data from the datatable to listview by converting the data table rows in to the collection.
33

4+
## Sample
5+
6+
```xaml
7+
<Grid Margin="0">
8+
<sync:SfListView x:Name="listView"
9+
ItemsSource="{Binding ContactsInfo}"
10+
ItemSize="70">
11+
<sync:SfListView.ItemTemplate>
12+
<DataTemplate>
13+
<ViewCell>
14+
<ViewCell.View>
15+
<Grid x:Name="grid" RowSpacing="0">
16+
<Grid.RowDefinitions>
17+
<RowDefinition Height="*" />
18+
<RowDefinition Height="1" />
19+
</Grid.RowDefinitions>
20+
<Grid RowSpacing="0" Padding="10,0,0,0">
21+
<Grid.ColumnDefinitions>
22+
<ColumnDefinition Width="70" />
23+
<ColumnDefinition Width="*" />
24+
<ColumnDefinition Width="Auto" />
25+
</Grid.ColumnDefinitions>
26+
27+
<Label LineBreakMode="NoWrap"
28+
TextColor="#474747" VerticalOptions="CenterAndExpand"
29+
Text="{Binding ItemArray[0]}">
30+
<Label.FontSize>
31+
<OnPlatform x:TypeArguments="x:Double">
32+
<On Platform="Android,iOS">
33+
<OnIdiom x:TypeArguments="x:Double" Phone="16" Tablet="18" />
34+
</On>
35+
<On Platform="UWP">
36+
<OnIdiom x:TypeArguments="x:Double" Phone="18" Tablet="20" Desktop="20" />
37+
</On>
38+
<On Platform="macOS" Value="18"/>
39+
</OnPlatform>
40+
</Label.FontSize>
41+
</Label>
42+
<Grid Grid.Column="1"
43+
RowSpacing="1"
44+
VerticalOptions="Center">
45+
<Grid.RowDefinitions>
46+
<RowDefinition Height="*" />
47+
<RowDefinition Height="*" />
48+
</Grid.RowDefinitions>
49+
50+
<Label LineBreakMode="NoWrap"
51+
TextColor="#474747"
52+
Text="{Binding ItemArray[1]}">
53+
<Label.FontSize>
54+
<OnPlatform x:TypeArguments="x:Double">
55+
<On Platform="Android,iOS">
56+
<OnIdiom x:TypeArguments="x:Double" Phone="16" Tablet="18" />
57+
</On>
58+
<On Platform="UWP">
59+
<OnIdiom x:TypeArguments="x:Double" Phone="18" Tablet="20" Desktop="20" />
60+
</On>
61+
<On Platform="macOS" Value="18"/>
62+
</OnPlatform>
63+
</Label.FontSize>
64+
</Label>
65+
<Label Grid.Row="1"
66+
Grid.Column="0"
67+
TextColor="#474747"
68+
LineBreakMode="NoWrap"
69+
Text="{Binding ItemArray[3]}">
70+
<Label.FontSize>
71+
<OnPlatform x:TypeArguments="x:Double">
72+
<On Platform="Android,iOS">
73+
<OnIdiom x:TypeArguments="x:Double" Phone="12" Tablet="14" />
74+
</On>
75+
<On Platform="UWP">
76+
<OnIdiom x:TypeArguments="x:Double" Phone="12" Tablet="12" Desktop="12" />
77+
</On>
78+
<On Platform="macOS" Value="14"/>
79+
</OnPlatform>
80+
</Label.FontSize>
81+
</Label>
82+
</Grid>
83+
<Grid Grid.Row="0"
84+
Grid.Column="2"
85+
RowSpacing="0"
86+
HorizontalOptions="End"
87+
VerticalOptions="Start">
88+
<Grid.Padding>
89+
<OnPlatform x:TypeArguments="Thickness">
90+
<On Platform="iOS">
91+
<OnIdiom x:TypeArguments="Thickness" Phone="0,10,10,0" Tablet="0,10,10,0" />
92+
</On>
93+
<On Platform="Android,UWP">
94+
<OnIdiom x:TypeArguments="Thickness" Phone="0,10,10,0" Tablet="0,10,10,0" Desktop="0,10,10,0" />
95+
</On>
96+
<On Platform="macOS" Value="0,10,15,0"/>
97+
</OnPlatform>
98+
</Grid.Padding>
99+
<Label LineBreakMode="NoWrap"
100+
TextColor="#474747"
101+
Text="{Binding ItemArray[2]}">
102+
<Label.FontSize>
103+
<OnPlatform x:TypeArguments="x:Double">
104+
<On Platform="Android,iOS">
105+
<OnIdiom x:TypeArguments="x:Double" Phone="10" Tablet="12" />
106+
</On>
107+
<On Platform="UWP">
108+
<OnIdiom x:TypeArguments="x:Double" Phone="10" Tablet="11" Desktop="11" />
109+
</On>
110+
<On Platform="macOS" Value="12"/>
111+
</OnPlatform>
112+
</Label.FontSize>
113+
</Label>
114+
</Grid>
115+
</Grid>
116+
<StackLayout Grid.Row="1" BackgroundColor="#E4E4E4" HeightRequest="1"/>
117+
</Grid>
118+
</ViewCell.View>
119+
</ViewCell>
120+
</DataTemplate>
121+
</sync:SfListView.ItemTemplate>
122+
</sync:SfListView>
123+
</Grid>
124+
```
125+
4126
See [How to bind data from the datatable to listview in Xamarin.Forms](https://www.syncfusion.com/kb/9697/how-to-bind-data-from-the-dattable-to-listview-in-xamarin-forms) for more details.
5127

6128
## <a name="requirements-to-run-the-demo"></a>Requirements to run the demo ##

0 commit comments

Comments
 (0)