2011-05-05 34 views
6

soy nuevo en WPF y necesito una manera de estirar un control treeview al tamaño completo disponible ... por lo que el estiramiento horizontal y vertical fue mi primera suposición, pero la vista de árbol se comporta como "Auto". ..WPF: Stretch treeview

estoy haciendo algo. mal aquí?

<Window 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" 
x:Class="WpfApplication2.MainWindow" 
x:Name="Window" 
Title="MainWindow" 
Width="500" Height="500" 
MinWidth="500" MinHeight="500"> 

<Grid> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="*"></RowDefinition> 
     <RowDefinition Height="Auto"></RowDefinition> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="*"></ColumnDefinition> 
    </Grid.ColumnDefinitions> 
    <StackPanel Grid.Row="0" Orientation="Vertical"> 
     <TreeView VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> 
      <TreeViewItem>asdasd</TreeViewItem> 
      <TreeViewItem>asdasd</TreeViewItem> 
     </TreeView> 
    </StackPanel> 
    <Label Grid.Row="1">asdasd</Label> 
</Grid> 
</Window> 

Respuesta

9

Has envuelto tu árbol en un StackPanel. Retire el StackPanel y probablemente obtendrá lo que está buscando.