C
C#7mo ago
stigzler

Have a WPF treeview stretch to fit its container

HI - having problems to achieve the above. My xaml:
<Grid Margin="5">
<Grid.Resources>
<HierarchicalDataTemplate DataType="{x:Type viewmodels:GistViewModel}" ItemsSource="{Binding Path=GistFiles}">
<TextBlock Text="{Binding GistFiles, Converter={StaticResource GistFilesToFirstFilenameConverter}}"></TextBlock>
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type viewmodels:GistFileViewModel}">
<TextBlock Text="{Binding Filename}"></TextBlock>
</DataTemplate>
</Grid.Resources>
<TreeView x:Name="GistsTV" Grid.Column="0" ItemsSource="{Binding Gists}">
</TreeView>
</Grid>
<Grid Margin="5">
<Grid.Resources>
<HierarchicalDataTemplate DataType="{x:Type viewmodels:GistViewModel}" ItemsSource="{Binding Path=GistFiles}">
<TextBlock Text="{Binding GistFiles, Converter={StaticResource GistFilesToFirstFilenameConverter}}"></TextBlock>
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type viewmodels:GistFileViewModel}">
<TextBlock Text="{Binding Filename}"></TextBlock>
</DataTemplate>
</Grid.Resources>
<TreeView x:Name="GistsTV" Grid.Column="0" ItemsSource="{Binding Gists}">
</TreeView>
</Grid>
It results in the attached image. The Treeview is the thin control at the bottom. Any advice?
No description
1 Reply
Buddy
Buddy7mo ago
You can use DockPanel, last element will be filled You don't have columns set though
<Grid.ColumnDefinitions>
</Grid.ColumnDefinitions>
<Grid.ColumnDefinitions>
</Grid.ColumnDefinitions>
Want results from more Discord servers?
Add your server