![](/img/trans.png)
[英]Binding data in Hub Control in Windows universal apps with list items
[英]Hub Control Universal Windows Apps
我正在为Windows(Windows 8.1和Windows Phone 8.1)构建通用应用程序。 我想使用仅具有2个选项卡的集线器控件,但是由于某些原因,背景将无法继续,或者它不会在第二个选项卡上显示背景。 当我只有一个标签时,它将在右侧显示一条黑线。 有办法解决这些问题吗?
问候,
汤姆
根据要求,我粘贴了我的代码。 轮毂部分可以放置几次。 当只有一两个时,它将不起作用。 当您添加第三个时,它将
<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>
您现在可能已经看到了。 但...
Hub
只有一个HubSection
,您认为它只有两个。 Hub
.Background,而不是您的HubSection
.Background。 祝你好运!
我认为问题不在于HUB或您使用的HubSection的数量。 我使用了以下代码:
<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>
并且背景会显示在每个HubSection上,无论是1、2还是3。请使用除“ HubBackgroundImageBrush”之外的其他画笔(如彩色画笔)尝试代码,并查看是否显示。
尝试这个
<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>
我不确定这是否仍然适用,但是根据链接的文章,当Hub控件只有一个部分时,它不会无限滚动...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.