C#C
C#2y 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>

It results in the attached image. The Treeview is the thin control at the bottom. Any advice?
image.png
Was this page helpful?