2

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 strings. 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!

1 Answer 1

2

Binding Path=. should do it, which can be shortened:

<Label Text="{Binding}" HorizontalOptions="Fill"/>

Assumes the ListView.ItemsSource remains CompanyList.

Sign up to request clarification or add additional context in comments.

1 Comment

THANKS! lol was stuck on this for a bit cause I didn't have a property to bind it ><". I'll accept when Stack allows me (time requirement). Thanks again!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.