2
<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>

这是一个默认的布局标题菜单和内容框架,我希望滚动查看器填充网格 Grid2 的第一列。我尝试了 margin VerticalAlignment height= "Auto",但它还没有工作。

4

1 回答 1

1

当您遇到填充和对齐问题时,查看是什么容器和/或子项导致此问题的一个好方法是为所有内容赋予不同的背景颜色。这样,你可以看到网格是否被拉伸,孩子长到哪里,......

这个问题已经解决了,但我只是想分享这个方法,因为它也帮助你找到了你的问题所在。

于 2012-08-20T08:28:26.150 回答