集线器控制通用Windows应用

时间:2014-04-29 07:31:31

标签: c# windows-phone-8 winrt-xaml windows-phone-8.1

我正在构建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>

4 个答案:

答案 0 :(得分:1)

你现在可能已经看到了。但...

  1. 您的Hub只有一个HubSection,您认为它有两个。
  2. 您的Hub。正在设置背景,而不是您的HubSection。背景
  3. 祝你好运!

答案 1 :(得分:0)

我认为问题不是来自HUB,也不是你使用的HubSections的数量。 我使用了以下代码:

                      

<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”之外的其他画笔尝试使用您的代码,就像使用颜色画笔一样,并查看它是否显示。

答案 2 :(得分:0)

试试这个

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

答案 3 :(得分:0)

我不确定这是否仍然适用但根据链接的文章,Hub控件在只有一个部分时无法无限滚动...

http://blogs.msdn.com/b/thunbrynt/archive/2014/04/08/windows-phone-8-1-for-developers-what-controls-are-new.aspx

相关问题