relacad
Topic Author
Posts: 7
Joined: 28 May 2025, 18:22

Best way to display dynamically updating table with Gridview

30 May 2025, 06:32

Hey there, relatively new to Noesis Studio and trying to create a basic table that's 3x3 to display data from a datamodel that will be updating in-game. This means that the 3x3 grid will populate with different column headers depending on which data reference is pulled, and the values will obviously change in kind.

For the sake of testing let's say everything is a string in a collection that is organized by row in the data structure:
[Row1] Header1, Header2, Header
[Row2] ValueA1, Value A2, ValueA3
[Row3] ValueB1, ValueB2, ValueB3

My understanding is that there are built-in table generation/display capabilities built into the gridview application of ListView, but for the life of me I can't get the binding, items, to work, I can get it to list items like a normal listbox for the collections (Header 1, 2, 3 or ValueA1, A2, A3) but I can't get it create columns or do Row1[0],Row2[0], Row3[0] etc.

If anyone could provide some insight on getting the columns to pull from data in general, or how to make tables with GridView, it'd be a great help! I just want to be like the controls gallery and make a table I can do selections in:
Screenshot 2025-05-30 002933.png
Any help would be greatly appreciated, I'm totally stumped.
 
User avatar
sfernandez
Site Admin
Posts: 3264
Joined: 22 Dec 2011, 19:20

Re: Best way to display dynamically updating table with Gridview

30 May 2025, 13:26

Hello,

The GridView.Columns property cannot be bound to data, it must be manually specified to define the ListView column structure.

There are ways to extend GridView with attached properties to be able to dynamically generate the columns using data, but that requires code: https://stackoverflow.com/questions/264 ... collection

For now the only thing that can be specified from data is the list of rows, ItemsSource, in the ListView:
<ListView ItemsSource="{Binding Users}">
  <ListView.View>
    <GridView>
      <GridViewColumn Header="Name" Width="120" DisplayMemberBinding="{Binding Name}" />
      <GridViewColumn Header="Age" Width="50" DisplayMemberBinding="{Binding Age}" />
      <GridViewColumn Header="Mail" Width="150" DisplayMemberBinding="{Binding Mail}" />
    </GridView>
  </ListView.View>
</ListView>
You can also configure the appearance of the column headers in the GridViewColumn.HeaderTemplate, and the appearance of each row cell with the GridViewColumn.CellTemplate.
 
relacad
Topic Author
Posts: 7
Joined: 28 May 2025, 18:22

Re: Best way to display dynamically updating table with Gridview

30 May 2025, 20:24

The GridView.Columns property cannot be bound to data, it must be manually specified to define the ListView column structure.


Thanks for the reply! I can see what you mean about data-bound headers. I'm now trying to test getting a standard table set up with static headers.

In Noesis studio, once I have created a set of headers (keeping with the same example here), I go into ListView and create a new template so that I can add a GridViewRowHeaderPresenter.

I am able to successfully drive it to produce the headers I specified in the properties editor for the ListView. In order to have the rows display with properly bound data, I created a new data-structure (Test_Table_Item_Model) and gave it 3 properties: Test_Table.Name, Test_Table.Format, and Test_Table.Count.

In my ViewModel I have both a single and collection of these datatypes (Test_ Table & Test_Table_Collection). I created 3 items in the collection to test populating the table.

For each GridView Column, I attached the DataMemberBinding to the Test_Table.Name, Test_Table.Format, and Test_Table.Count (the single item, not the collection) in my ViewModel and then I bind my ListView to the Table_Collection, which has the 3 items I created in the Test_Table_Collection dataset to test the table display.

Now here's my problem, when I bring in a GridRowPresenter, and bind via TemplatedParent to ListView.ItemsSource, but when I pull the columns via parent ListView.ColumnsCollection it no longer displays anything, and if I leave it to the default GridViewColumnCollection it just displays the collection name.

I'm not sure how to directly bind the GridViewColumn DisplayMemberBinding to the Test_Table_Item_Model, and binding them to the Test_Table instance in my ViewModel seems to be unable to allow the GridRowPresenter to properly display the items.

Any idea how best to proceed to create a 3x3 table in the studio that I can populate with a data structure made for it, and found as a collection in the ViewModel?
 
User avatar
sfernandez
Site Admin
Posts: 3264
Joined: 22 Dec 2011, 19:20

Re: Best way to display dynamically updating table with Gridview

04 Jun 2025, 11:14

I attached the DataMemberBinding to the Test_Table.Name, Test_Table.Format, and Test_Table.Count (the single item, not the collection) in my ViewModel
This doesn't make sense, because that will create a binding like this:
DisplayMemberBinding="{Binding Test_Table.Count}"
And then, when populating the rows, each column will try to solve that binding for each of the items. And that won't work because there is no Test_Table property defined for the item.

Here it is a small Studio project showing how to create a 3x3 table driven by data.
TestListView.zip
(2.85 KiB) Downloaded 16 times
 
relacad
Topic Author
Posts: 7
Joined: 28 May 2025, 18:22

Re: Best way to display dynamically updating table with Gridview

06 Jun 2025, 17:45

Hey Sfernandez,

Thanks so much. I was able to download the example and verify it was working. I found out that when I rebuilt the exact same data-template from scratch in my other project, the listview, unfortunately never displayed as a GridView, even though the option is selected. I think there is something funky going on between the studio assignment of gridview and the instance of it.

Looking at the XAML for the default GridView configuration from your project:
<ListView Height="300" HorizontalAlignment="Center" VerticalAlignment="Center" Width="500" ItemsSource="{Binding Path=Table}">
      <ListView.View>
        <GridView>
          <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=Name}" Width="150"/>
          <GridViewColumn DisplayMemberBinding="{Binding Path=Format}" Header="Format" Width="80"/>
          <GridViewColumn DisplayMemberBinding="{Binding Path=Count}" Header="Count" Width="80"/>
        </GridView>
      </ListView.View>
    </ListView>
Vs the one in my project when I create a ListView and set it to GridView via the View Property I get the following code:
<ListView Height="100" ItemsSource="{Binding Path=Table}">
                  <ListView.View>
                    <GridView/>
                  </ListView.View>
                </ListView>

The other thing I noticed is when I go to your original project and change the ListView View type to "none", and then back to "GridView" via the properties panel the XAML changes to produce the same <GridView/> that produces no GridView column binding:
<ListView Height="300" HorizontalAlignment="Center" VerticalAlignment="Center" Width="500" ItemsSource="{Binding Path=Table}">
      <ListView.View>
        <GridView/>
      </ListView.View>
    </ListView>
I tested adding custom templates with headers, and more. Unforunately the only way I could get the GridView to behave as described in my source project was replacing the <GridView/> with the functioning sample code directly in the MainPage.xaml . Is this working as intended or have I encountered a bug?
 
relacad
Topic Author
Posts: 7
Joined: 28 May 2025, 18:22

Re: Best way to display dynamically updating table with Gridview

06 Jun 2025, 18:36

I ended up posting a bug report on the GridView, after diving into more interactions there were some other elements not working (rebinding data not updating header columns).
 
User avatar
sfernandez
Site Admin
Posts: 3264
Joined: 22 Dec 2011, 19:20

Re: Best way to display dynamically updating table with Gridview

10 Jun 2025, 10:39

Ok, let's continue the conversation in the ticket you opened: #4232

Who is online

Users browsing this forum: No registered users and 0 guests