I have to insert dynamic columns in the TreeListView

Grids for WPF Forum

Posted 1 year ago by Mario
Version: 22.1.4
Avatar

Hi, I'm using the grid control
grids:TreeListViewe in the example Music Catalog .
i created three columns dynamically like this but i can't populate them

foreach (Autore  Autore in ListaAutori)
{

TreeListViewColumn column1 = new TreeListViewColumn();
column1.Header = Autore .Name;
treeListView.Columns.Add(column1);
}

After i call GenerateItems()

In the xaml I have not entered anything

Comments (3)

Answer - Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Mario,

From your sample code it appears you are defining the column header, but are not specifying how to obtain and display the data that goes in that column. In our Music Catalog demo, you will see each of our TreeListViewColumn definitions assign either a DataTemplate or a DisplayMemberBinding. You will need to replicate that logic in your code as well or the column will not "know" what to display for each item.

If you continue to have issues with dynamically adding columns, please create a small sample application that demonstrates the issue and send to our support email with a reference to this forum post so we can better assist you. Please be sure to remove any BIN/OBJ folders before zipping the sample so the attachment does not get SPAM-blocked.


Actipro Software Support

Posted 1 year ago by Mario
Avatar

i send the example to mailer@.

i insert this code

<grids:TreeListViewColumn Header="{Binding Autore[0]}" Width="74" >
<DataTemplate>
<TextBlock Text="{Binding Autore[0]}" />
</DataTemplate>
</grids:TreeListViewColumn>

Io look only <TextBlock Text="{Binding Autore}" /> if a populate

albumModel.Children.Add(new TrackTreeNodeModel() { Name = "Spinning", Length = "6:03", Popularity = 2 , Months = new ObservableCollection<string> { "Jan", "Feb", "Mar", "Apr" } });

and i look only header if a populate

string[] Autors = { "Autore0", "Autore1", "Autore2", "Autore3" };

foreach (var mon in Autors)
{
TreeListViewColumn column1 = new TreeListViewColumn();
column1.Header = mon;
column1.DisplayMemberBinding = new System.Windows.Data.Binding(mon);
treeListView.Columns.Add(column1);
}

then I'm forced to insert all the columns in the grid instead I would like to insert only one dynamic one

[Modified 1 year ago]

Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Mario,

The "mailer@" address is only used for outgoing mail and is not monitored. Could you please send to "support@" address? I'm not entirely clear what you are attempting or the outcomes you are seeing, so please make sure the sample fully compiles and demonstrates the issue. If necessary, please also include steps to reproduce the issue and a clear statement of what was expected compared to the actual results.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.