2016-07-06 63 views
1

我使用命令欄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> 

我越來越像下面頁腳圖標與任何背景。只顯示圖標圖像。

enter image description here

但我需要這樣一個頁腳圖標一些圓角的背景每個圖標前景色白色

enter image description here

請指引我達到了預期

+0

我敢說「你試過了什麼?」 「你面臨什麼問題?」 「你感到困惑的是什麼?」 –

+0

我使用我發佈的代碼實現了命令欄。我附上了基於我已經使用的代碼的圖像(第一圖像),但我想實現頁腳作爲第二圖像 – Anbarasi

+0

因此添加更多的按鈕? –

回答

0

嘗試按照如下:

1)打開您想要修改的Blend中的頁面。點擊實際的控制並單擊右鍵。

enter image description here

2)在彈出的窗口中選擇創建新的模板,並定義爲應用

enter image description here

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> 

這是混合之美。不只是這個控件,你可以修改任何具有樣式模板的控件。

祝你好運。

+0

謝謝AVK Naidu。它的工作很好 – Anbarasi