Answered my own post -- how to read ObservableCollection to an array --

tim 200 Reputation points
2024-05-11T13:45:01.4433333+00:00

I may be doing this the wrong way, I want to read all the Line in my listview to be able to add them to an array.

xaml

<ListView ItemsSource="{Binding MyItems}" IsGroupingEnabled="True" GroupShortNameBinding="{Binding Key}" GroupDisplayBinding="{Binding Key}" HasUnevenRows="True" >

            <ListView.ItemTemplate >

                <DataTemplate>

                    <ViewCell>

                        <StackLayout Orientation="Horizontal">                               

                            <Label Text="{Binding Amountc}"                               

                                   HorizontalOptions="CenterAndExpand"  FontAttributes="Bold"

                                   VerticalOptions="CenterAndExpand"/>
```**CS code  -I'm getting the error on the Amountc , not sure what I need to use.**

 Linecount = MyItems.Count;

```r
          for (int li = 0; li < Linecount; li++)

            {

             CollectedData[li] = MyItems.ElementAt(li).**Amountc**;        

        }
```TIA.

Tim

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,249 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,094 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.