Reputation: 8206
ObservableCollection<string> CompanyList
in the xaml.cs code behind is tied to <ListView>
element in the xaml. Left alone, it displays a list of the strings in CompanyList
as expected.
However, I want to customize (purely for style purposes) the ViewCell
in the ListView
while leaving CompanyList
as a collection of string
s. I am unsure how to bind the string
company list value.
<ListView x:Name="CompanyList" ItemTapped="OnAddCompanyFilterTapped" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="0" Spacing="0">
<StackLayout Padding="10">
<Label Text="{Binding ??????????}" HorizontalOptions="Fill"/>
</StackLayout>
<BoxView Style="{StaticResource divider}"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
What do I put in the ??????? to get the string in CompanyList
to show?
Any help/suggestions/ideas is greatly appreciated!
Upvotes: 2
Views: 2076
Reputation: 2363
Binding Path=.
should do it, which can be shortened:
<Label Text="{Binding}" HorizontalOptions="Fill"/>
Assumes the ListView.ItemsSource
remains CompanyList
.
Upvotes: 2