Problem with filling control
I have problem with filling control.
In first column I have stackpanel and it has 4 controls. Every ScrollViewer as DataContext has TreeView, which has Height set as Auto. When I expand nodes in my treviews it expands out of window. How can I fix it ?
<Grid x:Name="MainGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".30*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width=".69*"/>
</Grid.ColumnDefinitions>
<Border CornerRadius="0" BorderBrush="#58290A"
BorderThickness="5" Grid.Column="0" >
<StackPanel MaxHeight="{Binding Height, ElementName=MainGrid}">
<ScrollViewer x:Name="ScrollViewerForOperationTree">
</ScrollViewer>
<Button Content="Dodaj brakujący hotel" Click="AddHotel_Click" x:Name="btnAddHotel">
</Button>
<Button Content="Dodaj brakujące miasto" Click="AddCity_Click" x:Name="AddCity"></Button>
<ScrollViewer x:Name="ScrollViewerForSimpleTree"></ScrollViewer>
</StackPanel>
</Border>
<GridSplit开发者_开发技巧ter HorizontalAlignment="Right"
VerticalAlignment="Stretch"
Grid.Column="1" ResizeBehavior="PreviousAndNext"
Width="5" Background="#FFBCBCBC"/>
<Grid Grid.Column="2" Background="#B5CBEF" x:Name="GridObjectOperation">
</Grid>
</Grid>
StackPanel will give its children as much vertical space as they request, even if there isn't enough available, so the later elements will fall off the end. Try using a Grid instead:
<Border CornerRadius="0" BorderBrush="#58290A"
BorderThickness="5" Grid.Column="0" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0" x:Name="ScrollViewerForOperationTree">
</ScrollViewer>
<Button Grid.Row="1" Content="Dodaj brakujący hotel"
Click="AddHotel_Click" x:Name="btnAddHotel">
</Button>
<Button Grid.Row="2" Content="Dodaj brakujące miasto"
Click="AddCity_Click" x:Name="AddCity"></Button>
<ScrollViewer Grid.Row="3" x:Name="ScrollViewerForSimpleTree">
</ScrollViewer>
</Grid>
</Border>
精彩评论