适用于WindowsPhone的TopAppbar和BottomAppBar

时间:2015-12-22 14:02:07

标签: windows-phone-8.1 windows-phone-8-emulator

我的通用应用程序中有一个TopAppbar和BottomAppBar,我想在我的Windows Phone 8中创建相同的AppBars,这是我的代码:

<Page.TopAppBar>
        <CommandBar HorizontalContentAlignment="Stretch" Background="#FF00AEEF">
            <CommandBar.Content >
                <Grid>
                    <StackPanel Orientation="Horizontal"
                        HorizontalAlignment="Left">
                        <StackPanel Orientation="Horizontal" >
                            <Image Margin="2" Height="35" Source="images/4.png" Width="35"/>
                        </StackPanel>
                        <Button VerticalAlignment="Stretch" Background="#FF00AEEF" x:Name="HomeBtn" Click="HomeBtn_Click">
                            <StackPanel Orientation="Horizontal">
                                <Image Source="images/berry.png" Height="35" Width="35" />
                                <TextBlock Text="BarBerry"  Foreground="White"></TextBlock>
                            </StackPanel>
                        </Button>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                        <Button VerticalAlignment="Stretch" Background="#FF00AEEF" Style="{StaticResource CustomButtonStyle}" Margin="5,0">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Contact" Foreground="White"></TextBlock>
                            </StackPanel>
                        </Button>
                    </StackPanel>
                </Grid>
            </CommandBar.Content>
        </CommandBar>
    </Page.TopAppBar>

    <Page.BottomAppBar>
        <CommandBar Background="#eff0f2" HorizontalContentAlignment="Stretch">
            <CommandBar.Content>
                <Grid HorizontalAlignment="Stretch">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal"
                        HorizontalAlignment="Left" Grid.Row="0" Grid.Column="0" VerticalAlignment="Stretch">
                        <Image Source="images/world.png" Height="35" Width="35" Margin="5,0"/>
                        <ComboBox Margin="2" BorderThickness="0" SelectedItem="test" x:Name="combo">
                            <ComboBoxItem Content="test" />
                            <ComboBoxItem Content="test1" />
                        </ComboBox>
                    </StackPanel>
                </Grid>
            </CommandBar.Content>
        </CommandBar>
    </Page.BottomAppBar>

但问题是,我只显示了BottomAppBar,是否可以在Windows Phone 8中定义顶部和底部AppBars,我应该使用StackPanel代替Top appBar吗?

感谢您的帮助

1 个答案:

答案 0 :(得分:1)

您无法在Windows手机中创建热门应用栏。因为他们只是底部应用程序栏是在Windows手机项目中定义的。所以你只能在windows phone中定义底部应用栏。是的,你可以使用 Stack面板而不是Top App栏,但我认为在windows phone中实现这种功能并不是一个好主意。 :)