Search code examples
xamlwinrt-xamlvisual-studio-2015blendwindows-10-mobile

Different XAML Hub content aligment in design mode and in emulator


I have a StackPanel representing the top bar and a Hub representing books items. Both wrapped in the grid with two rows. The problem is that in design mode hub content aligned properly to the top, just below my top bar. But in emulator it looks like all content aligned to the center of the hub.
In design time it looks like this:
Design time view
But in emulator it looks like this:
Emulator view
Here is my XAML code:

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

Solution

  • Ho-ho-ho... I finally managed to find the problem. After spending WEEKS!!! WEEKS, Carl! After spending few weeks I found out by accident that there is a MASSIVE "application name" <Hub.title> above my <Grid>. It was not visible because of the white background and white font color of the text. By accidentally changing <RequestedTheme="Light"> I was finally able to see this text, because default font color changed to black. The text "application name" itself was not in my XAML source file, it was attached by localization facilities with x:Uid ="Hub" and corresponding value in resources.resw. After deleting x:Uid my layout returned to normal...