Thanks for the quick reply.
The number of columns could be anything, after the first 2.
I'm able to generate the columns using an attached property (below for reference, slightly modified), however I'm not quite sure how to go about hooking up the information that should be in that column.
i.e. in the example I have a 'Columns' collection on the ViewModel, the Root of the TreeListView is 'StepsForTreeView', each step has another collection in it which becomes the data for the columns. Using 'DisplayMemberBinding' on the dynamically created columns works, but their template is just a TextBlock, I cannot figure out how to appropriately assign a CellTemplate.
(I know this is a little off the beaten path, and not specifically an 'issue' with the control, just hoping for a suggestion from the developer. THANKS)
<actiproGrids:TreeListView recipeStepper:CollectionToTreeListViewColumnHelper.ControlPoints="{Binding Columns}" RootItem="{Binding StepsForTreeView}">
public class CollectionToTreeListViewColumnHelper : DependencyObject
{
public static ColumnList GetColumns(DependencyObject d)
{
return (ColumnList)d.GetValue(ColumnsProperty);
}
public static void SetColumns(DependencyObject d, ColumnList value)
{
d.SetValue(ColumnsProperty, value);
}
public static readonly DependencyProperty
ColumnsProperty = DependencyProperty.RegisterAttached("Columns",
typeof(ColumnList),
typeof(CollectionToTreeListViewColumnHelper),
new PropertyMetadata(
new PropertyChangedCallback(OnColumnsChanged)));
private static void OnColumnsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var tree = (TreeListView)d;
var columnss = (ColumnList)e.NewValue;
if (columns == null) return;
int pt = 0;
foreach (var col in columns)
{
var newcolumn = new TreeListViewColumn();
newcolumn.Header = col.Name;
//newcolumn.CellTemplate = // tbd..
//newcolumn.DisplayMemberBinding = new Binding($"Actions[{pt}]"); // this does not work either. needs Template.
tree.Columns.Add(newcolumn);
pt++;
}
}
}