以下のコードを使用して、WindowsPhoneでコマンドバーを使用しています
<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>
以下のようなフッターアイコンが背景なしで表示されます。単にアイコン画像が表示されています。
しかし、前景が白のアイコンごとに、背景が丸みを帯びたこのようなフッターアイコンが必要です
期待を達成するために私を導いてください
以下に従ってください:
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>
これがBeautyofBlendです。このコントロールだけでなく、スタイルテンプレートを持つ任意のコントロールを変更できます。
がんばろう。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加