0

我有一个代表顶部栏的 StackPanel 和一个代表书籍项目的 Hub。两者都包裹在两排网格中。问题是在设计模式下,中心内容与顶部正确对齐,就在我的顶栏下方。但在模拟器中,看起来所有内容都与中心的中心对齐。
在设计时它看起来像这样:
但在模拟器中它看起来像这样:这是我的 XAML 代码:设计时视图

模拟器视图

<Page.Resources>
        <DataTemplate x:Key="HubSectionHeaderTemplate">
            <TextBlock Margin="0,0,0,-10" Text="{Binding}" FontSize="19" FontFamily="Open Sans" FontWeight="Light" FontStretch="ExtraExpanded" Foreground="#FF30323E">
                <!--<TextBlock.RenderTransform>
                    <CompositeTransform/>
                </TextBlock.RenderTransform>-->
            </TextBlock>
        </DataTemplate>

        <!-- Grid-appropriate item template as seen in section 2 -->
        <DataTemplate x:Key="Standard200x180TileItemTemplate">
            <Grid Margin="0,0,15,15" Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" VerticalAlignment="Top">
                <Image Source="{Binding ImagePath}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}" Height="165" Width="115"/>
                <!--<TextBlock Text="{Binding Title}" VerticalAlignment="Bottom" Margin="9.5,0,0,6.5" Style="{ThemeResource BaseTextBlockStyle}"/>-->
            </Grid>
        </DataTemplate>

    </Page.Resources>

    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="60"/>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Margin="0,-25,0,0">
            <StackPanel.Background>
                <ImageBrush ImageSource="Assets/CatalogTopBar.png" Stretch="UniformToFill"/>
            </StackPanel.Background>
            <Button x:Name="searchButton" Margin="0,25,-30,0" Height="15" Width="10" Content="" HorizontalAlignment="Right" VerticalAlignment="Center" BorderThickness="0" >
                <Button.Background>
                    <ImageBrush ImageSource="Assets/noun_23695_cc.png" Stretch="Uniform"/>
                </Button.Background>
            </Button>
        </StackPanel>

        <Hub x:Name="Hub" x:Uid="Hub" Grid.Row="1" Background="White" Margin="0,25,0,0"  VerticalContentAlignment="Top" VerticalAlignment="Top">
            <HubSection x:Uid="HubSection2" Header="Популярные книги" Width="Auto"
                         DataContext="{Binding Groups[0]}" HeaderTemplate="{ThemeResource HubSectionHeaderTemplate}" >
                <DataTemplate>
                    <GridView
                        Margin="0,-10,0,0"
                        ItemsSource="{Binding Items}"
                        AutomationProperties.AutomationId="ItemGridView"
                        AutomationProperties.Name="Items In Group"
                        ItemTemplate="{StaticResource Standard200x180TileItemTemplate}"
                        SelectionMode="None"
                        IsItemClickEnabled="True"
                        ItemClick="ItemView_ItemClick"
                        ContinuumNavigationTransitionInfo.ExitElementContainer="True">
                        <GridView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <ItemsWrapGrid />
                            </ItemsPanelTemplate>
                        </GridView.ItemsPanel>
                    </GridView>
                </DataTemplate>
            </HubSection>

        </Hub>

    </Grid>
</Page>
4

1 回答 1

0

嗬嗬嗬……我终于找到了问题所在。花费数周后!!!几周,卡尔!花了几个星期后,我偶然发现"application name" <Hub.title>我的<Grid>. 由于文本的白色背景和白色字体颜色,它不可见。由于意外更改<RequestedTheme="Light">,我终于能够看到此文本,因为默认字体颜色更改为黑色。文本“应用程序名称”本身不在我的 XAML 源文件中,它由本地化工具附加,x:Uid ="Hub"并带有resources.resw. 删除后x:Uid我的布局恢复正常...

于 2015-09-10T14:35:16.970 回答