![](/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.