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

tim 120 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.
4,697 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.
10,382 questions
{count} votes