79314453

Date: 2024-12-28 20:01:21
Score: 0.5
Natty:
Report link

This is not a question, but just a comment that may help others that have found this thread (Note that I'm an old C programmer, so C#, XAML, .Net Maui, & Object Orientation are all new to me). I wanted to simply display a table with a variable # of rows, and also needed to calculate some of the cells on the fly. My thinking was to define the table in XAML, and then add additional rows & values in my C# code-behind. I started with a Grid, but couldn't figure out how to add the rows dynamically so I started researching and found TableView, ListView, DataTable, DataGrid, and something magical called FlexLayout. I also tried combinations thereof, to no avail. I finally stumbled on the Grid Methods of "AddRowDefinition" and "Childen.Add" and discovered that I could solve my problem by going back to my simple Grid, wrapped inside a ScrollView. I'm sure there are more elegant solutions, but the below seems to work (note that recently I discovered "Table" in xaml which sounds promising, but that was after I came up with the soln below) For an example, the code below simply calculates the Squares & Square Roots of the first N integers, and displays them table format (XAML code first, followed by the C# code): Code will be include in following posts.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Low reputation (1):
Posted by: CraigP