Windows Phone中的命令栏

安巴拉西

我正在使用以下代码在Windows Phone中使用命令栏

<Page.BottomAppBar>
        <CommandBar Foreground="White">
            <CommandBar.PrimaryCommands>
                <AppBarButton x:Uid="Share">
                    <AppBarButton.Icon>
                        <BitmapIcon UriSource="/Assets/Share.png"/>
                    </AppBarButton.Icon>
                </AppBarButton>
                <AppBarButton Icon="Favorite"></AppBarButton>
                <AppBarButton Icon="Comment"></AppBarButton>
            </CommandBar.PrimaryCommands>
        </CommandBar>
    </Page.BottomAppBar>

我在没有任何背景的情况下得到如下所示的页脚图标。仅显示图标图像。

在此处输入图片说明

但是我需要一个像这样的页脚图标,每个带有前景白色的图标都带有一些圆角的背景

在此处输入图片说明

请指导我实现预期的目标

AVK

尝试遵循以下步骤:

1)在Blend中打开要修改的页面。单击实际的控件,然后单击鼠标右键。

在此处输入图片说明

2)从弹出窗口中选择创建新模板并定义为应用程序

在此处输入图片说明

3)它在App.xaml中创建默认模板的副本。现在ContentPresenter,在样式结束前查找标签它将使用名称ContentRoot包装在StackPanel中。用边框包裹它。

<Border BorderBrush="{TemplateBinding Foreground}" CornerRadius="50" BorderThickness="2" Margin="10,0">

最后应该是下面的样子。

<Border BorderBrush="{TemplateBinding Foreground}" CornerRadius="50" BorderThickness="2" Margin="10,0">
    <StackPanel x:Name="ContentRoot" MinHeight="{ThemeResource AppBarThemeCompactHeight}">
        <ContentPresenter x:Name="Content" AutomationProperties.AccessibilityView="Raw" Content="{TemplateBinding Icon}" Foreground="{TemplateBinding Foreground}" HorizontalAlignment="Center" Height="20" Width="20" Margin="0,12,0,4"/>
        <TextBlock x:Name="TextLabel" Foreground="{TemplateBinding Foreground}" FontSize="12" FontFamily="{TemplateBinding FontFamily}" Margin="0,0,0,6" TextAlignment="Center" TextWrapping="Wrap" Text="{TemplateBinding Label}"/>
    </StackPanel>
</Border>

现在返回页面并将样式设置为此样式键。像下面。

<AppBarButton Icon="Favorite" Style="{StaticResource AppBarButtonStyle1}" ></AppBarButton>

这是混合之美。不仅是此控件,还可以修改任何具有样式模板的控件。

祝你好运。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章