如何调整MaxHeight
的{{1}},MaxWidth
和TreeView
的{{1}}以适应窗口的大小? (预览中的XXX个值)
MaxWidth
答案 0 :(得分:0)
如果只需要使用窗口来调整树视图的大小,则可以使用网格行和列定义。
<Window x:Class="MyApplication.MyWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyApplication"
Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<TreeView x:Name="myTreeView" Background="SteelBlue" Grid.Row="0" Grid.Column="0">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="DataType="{x:Type local:TreeParentClass}"
ItemsSource="{Binding TreeParentMembers}">
<TextBlock Text="{Binding Title}"/>
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>
<Border Background="DarkGray" Grid.Row="1" Grid.Column="0"/>
<Border Background="LightCoral" Grid.Row="0" Grid.Column="1" Grid.RowSpan="2"/>
</Grid>
</Window>