TreeListView in Avalonia #5585
Answered
by
Gramli
ShrutiJaiswal1494
asked this question in
Q&A
-
I need to create a TreeView that shows data like a DataGrid such that I have a TreeView at left side with columns at right side. I see in WPF we can achieve this using a TreeListView. Is something like this available for avalonia? |
Beta Was this translation helpful? Give feedback.
Answered by
Gramli
Mar 9, 2021
Replies: 2 comments 1 reply
-
Did you tried create custom TreeDataTemplate? Something like this: <TreeView Items="{Binding Items}">
<TreeView.DataTemplates>
<TreeDataTemplate ItemsSource="{Binding SubItems}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name}" Grid.Column="0"/>
<TextBlock Text="{Binding Text}" Grid.Column="1"/>
</Grid>
</TreeDataTemplate>
</TreeView.DataTemplates>
</TreeView> |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hope I understand, you can set Column.Width, then the second, third .. columns will be aligned. <TreeView Items="{Binding Items}">
<TreeView.DataTemplates>
<TreeDataTemplate DataType="models:Item" ItemsSource="{Binding SubItems}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name}" Grid.Column="0"/>
<TextBlock Text="{Binding Type}" Grid.Column="1"/>
<TextBlock Text="{Binding Data}" Grid.Column="2"/>
</Grid>
</TreeDataTemplate>
</TreeView.DataTemplates>
</TreeView> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ShrutiJaiswal1494
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hope I understand, you can set Column.Width, then the second, third .. columns will be aligned.