<navigation:Page
d:DesignHeight="768" d:DesignWidth="1366">
<UserControl.Resources>
<sdk:HierarchicalDataTemplate x:Key="Level3">
<StackPanel Orientation="Horizontal">
<ContentPresenter Margin="0 0 4 0" Content="{Binding IconUri}"/>
<HyperlinkButton x:Name="TemplateLinkButton" Content="{Binding MenuCaption}" NavigateUri="{Binding Uri}"/>
</StackPanel>
</sdk:HierarchicalDataTemplate>
<sdk:HierarchicalDataTemplate x:Key="Level2" ItemsSource="{Binding Path=Children}" ItemTemplate="{StaticResource Level3}">
<StackPanel Orientation="Horizontal">
<ContentPresenter Margin="0 0 4 0" Content="{Binding IconUri}"/>
<HyperlinkButton x:Name="TemplateLinkButton" Content="{Binding MenuCaption}" NavigateUri="{Binding Uri}"/>
</StackPanel>
</sdk:HierarchicalDataTemplate>
<sdk:HierarchicalDataTemplate x:Key="Level1" ItemsSource="{Binding Path=Children}" ItemTemplate="{StaticResource Level2}">
<StackPanel Orientation="Horizontal">
<ContentPresenter Margin="0 0 4 0" Content="{Binding IconUri}"/>
<TextBlock Text="{Binding Path=MenuCaption}"/>
</StackPanel>
</sdk:HierarchicalDataTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" ShowGridLines="True" Background="Blue">
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Text="Header" Name="textBlockHeader"/>
<Grid Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ShowGridLines="True" Background="Pink">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ScrollViewer Height="Auto" Background="CadetBlue">
<sdk:TreeView Name="menuTree" ItemTemplate="{StaticResource Level1}" Background="Fuchsia">
</sdk:TreeView>
</ScrollViewer>
<sdk:Frame HorizontalAlignment="Stretch" Grid.Column="1" VerticalAlignment="Stretch" Source="" Name="contentFrame">
<sdk:Frame.UriMapper>
<sdk:UriMapper>
<sdk:UriMapping MappedUri="/VIEW/{page}.xaml" Uri="/{page}" />
</sdk:UriMapper>
</sdk:Frame.UriMapper>
</sdk:Frame>
</Grid>
</Grid>
</navigation:Page>
这是一个默认的布局标题菜单和内容框架,我希望scrollviewer填充网格Grid2的第一列。我尝试了保证金VerticalAlignment
height= "Auto"
,但它还没有用。
答案 0 :(得分:1)
当您在填充和对齐方面遇到问题时,查看容器和/或子容器导致此问题的一种好方法是为所有内容提供不同的背景颜色。这样,您可以看到网格是否被拉伸,孩子在哪里成长,......
这个问题已经解决了,但我只想分享这个方法,因为它帮助你找到了你的错误。