Reputation: 1324
I'm building an universal application for windows (windows 8.1 and windows phone 8.1). I want to use a hub control with only 2 tabs, but for some reason the background won't continue or it won't show the background on the second tab. When I only have one tab it will show a black line on the right. Is there a way to fix those things?
Regards,
Tom
By request i pasted my code. The hubsection can be placed several times. When there is only one or two it won't work. When you add the third it will
<Page
x:Class="RestaurantApp.ListPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:RestaurantApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
DataContext="{Binding Source={StaticResource MainVM}}"
mc:Ignorable="d" >
<!--<Page.Transitions>
<TransitionCollection>
<NavigationThemeTransition>
<NavigationThemeTransition.DefaultNavigationTransitionInfo>
<ContinuumNavigationTransitionInfo></ContinuumNavigationTransitionInfo>
</NavigationThemeTransition.DefaultNavigationTransitionInfo>
</NavigationThemeTransition>
</TransitionCollection>
</Page.Transitions>-->
<Grid x:Name="LayoutRoot">
<Hub x:Name="Hub" x:Uid="Hub" Header="ducommerce" Background="{StaticResource HubBackgroundImageBrush}">
<HubSection x:Uid="HubSection1" Header="{Binding SpecialDishes.Name}" >
<DataTemplate>
<ListView
ItemsSource="{Binding SpecialDishes.Items}"
IsItemClickEnabled="True"
ContinuumNavigationTransitionInfo.ExitElementContainer="True" ItemTemplate="{StaticResource SmallImageItemWithDescription}">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="0,0,0,12"/>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</DataTemplate>
</HubSection>
</Hub>
</Grid>
</Page>
Upvotes: 0
Views: 3551
Reputation: 767
I'm not sure if this still holds true but according to the linked article the Hub control does not scroll infinitely when it has only one section...
Upvotes: 0
Reputation: 92
Try this
<Hub Header="The Header" Margin="0,27,0,0">
<Hub.HeaderTemplate>
<DataTemplate>
<TextBlock Text="The Text" FontSize="66"></TextBlock>
</DataTemplate>
</Hub.HeaderTemplate>
<Hub.Background>
<ImageBrush ImageSource="Assets/TheBackground.jpg" Stretch="UniformToFill"/>
</Hub.Background>
</Hub>
Upvotes: 0
Reputation: 1557
I think the problem does not come from the HUB, or the number of HubSections you use. I've used the following code:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid x:Name="LayoutRoot">
<Hub x:Name="Hub" x:Uid="Hub" Header="ducommerce" Background="{StaticResource background}">
<HubSection x:Uid="HubSection1" Header="{Binding SpecialDishes.Name}" >
<DataTemplate>
<ListView
ItemsSource="{Binding Items}"
IsItemClickEnabled="True">
<ListView.ItemTemplate>
<DataTemplate>
<Button Content="testbtn"></Button>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="0,0,0,12"/>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</DataTemplate>
</HubSection>
<HubSection x:Uid="HubSection1" Header="{Binding SpecialDishes.Name}" >
<DataTemplate>
<ListView
ItemsSource="{Binding Items}"
IsItemClickEnabled="True">
<ListView.ItemTemplate>
<DataTemplate>
<Button Content="testbtn"></Button>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="0,0,0,12"/>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</DataTemplate>
</HubSection>
<!--<HubSection x:Uid="HubSection1" Header="{Binding SpecialDishes.Name}" >
<DataTemplate>
<ListView
ItemsSource="{Binding Items}"
IsItemClickEnabled="True">
<ListView.ItemTemplate>
<DataTemplate>
<Button Content="testbtn"></Button>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="0,0,0,12"/>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</DataTemplate>
</HubSection>-->
</Hub>
</Grid>
</Grid>
And the background is displayed on every HubSection, whether there are 1, 2 or 3. Try your code with another brush than your "HubBackgroundImageBrush", like a color brush, and see if it is shown.
Upvotes: 0
Reputation: 31831
You probably see this by now. But...
Hub
only has a single HubSection
, you think it has two.Hub
.Background is being set, not your HubSection
.BackgroundBest of luck!
Upvotes: 1