RichTextBox for UWP
手順2:リソースファイルと一般的なアプリケーションコードの追加
チュートリアル > AppBar アプリケーションの作成 > 手順2:リソースファイルと一般的なアプリケーションコードの追加
  1. この手順では、スタイルを含むリソースファイルと、アプリケーションが使用するコンテンツを追加します。アプリケーション名を右クリックし、[追加]→[新しいフォルダ]を選択します。新しいフォルダ名を Common と指定します。
    1. Common フォルダを右クリックし、[追加]→[新しい項目]を選択します。
    2. [新しい項目の追加] ダイアログウィンドウの利用可能なテンプレートから[空白のページ]を選択します。これに、StandardStyles.xaml という名前を付け、[OK]をクリックします。
    3. ファイルが開いたら、次の XAML マークアップを追加します。

      XAML でマークアップの書き方

      XAML マークアップ
      コードのコピー
      <ResourceDictionary
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
          <!-- Non-brush values that vary across themes -->
          <ResourceDictionary.ThemeDictionaries>
              <ResourceDictionary x:Key="Default">
                  <x:String x:Key="BackButtonGlyph">&#xE071;</x:String>
                  <x:String x:Key="BackButtonSnappedGlyph">&#xE0BA;</x:String>
              </ResourceDictionary>
              <ResourceDictionary x:Key="HighContrast">
                  <x:String x:Key="BackButtonGlyph">&#xE071;</x:String>
                  <x:String x:Key="BackButtonSnappedGlyph">&#xE0C4;</x:String>
              </ResourceDictionary>
          </ResourceDictionary.ThemeDictionaries>
          <x:String x:Key="ChevronGlyph">&#xE26B;</x:String>
          <!-- RichTextBlock styles -->
          <Style x:Key="BasicRichTextStyle" TargetType="RichTextBlock">
              <Setter Property="Foreground" Value="{ThemeResource ApplicationForegroundThemeBrush}"/>
              <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/>
              <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/>
              <Setter Property="TextTrimming" Value="WordEllipsis"/>
              <Setter Property="TextWrapping" Value="Wrap"/>
              <Setter Property="Typography.StylisticSet20" Value="True"/>
              <Setter Property="Typography.DiscretionaryLigatures" Value="True"/>
              <Setter Property="Typography.CaseSensitiveForms" Value="True"/>
          </Style>
          <Style x:Key="BaselineRichTextStyle" TargetType="RichTextBlock" BasedOn="{StaticResource BasicRichTextStyle}">
              <Setter Property="LineHeight" Value="20"/>
              <Setter Property="LineStackingStrategy" Value="BlockLineHeight"/>
              <!-- Properly align text along its baseline -->
              <Setter Property="RenderTransform">
                  <Setter.Value>
                      <TranslateTransform X="-1" Y="4"/>
                  </Setter.Value>
              </Setter>
          </Style>
          <Style x:Key="ItemRichTextStyle" TargetType="RichTextBlock" BasedOn="{StaticResource BaselineRichTextStyle}"/>
          <Style x:Key="BodyRichTextStyle" TargetType="RichTextBlock" BasedOn="{StaticResource BaselineRichTextStyle}">
              <Setter Property="FontWeight" Value="SemiLight"/>
          </Style>
          <!-- TextBlock styles -->
          <Style x:Key="BasicTextStyle" TargetType="TextBlock">
              <Setter Property="Foreground" Value="{ThemeResource ApplicationForegroundThemeBrush}"/>
              <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/>
              <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/>
              <Setter Property="TextTrimming" Value="WordEllipsis"/>
              <Setter Property="TextWrapping" Value="Wrap"/>
              <Setter Property="Typography.StylisticSet20" Value="True"/>
              <Setter Property="Typography.DiscretionaryLigatures" Value="True"/>
              <Setter Property="Typography.CaseSensitiveForms" Value="True"/>
          </Style>
          <Style x:Key="BaselineTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BasicTextStyle}">
              <Setter Property="LineHeight" Value="20"/>
              <Setter Property="LineStackingStrategy" Value="BlockLineHeight"/>
              <!-- Properly align text along its baseline -->
              <Setter Property="RenderTransform">
                  <Setter.Value>
                      <TranslateTransform X="-1" Y="4"/>
                  </Setter.Value>
              </Setter>
          </Style>
          <Style x:Key="HeaderTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}">
              <Setter Property="FontSize" Value="56"/>
              <Setter Property="FontWeight" Value="Light"/>
              <Setter Property="LineHeight" Value="40"/>
              <Setter Property="RenderTransform">
                  <Setter.Value>
                      <TranslateTransform X="-2" Y="8"/>
                  </Setter.Value>
              </Setter>
          </Style>
          <Style x:Key="SubheaderTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}">
              <Setter Property="FontSize" Value="26.667"/>
              <Setter Property="FontWeight" Value="Light"/>
              <Setter Property="LineHeight" Value="30"/>
              <Setter Property="RenderTransform">
                  <Setter.Value>
                      <TranslateTransform X="-1" Y="6"/>
                  </Setter.Value>
              </Setter>
          </Style>
          <Style x:Key="TitleTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}">
              <Setter Property="FontWeight" Value="SemiBold"/>
          </Style>
          <Style x:Key="SubtitleTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}">
              <Setter Property="FontWeight" Value="Normal"/>
          </Style>
          <Style x:Key="ItemTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}"/>
          <Style x:Key="BodyTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}">
              <Setter Property="FontWeight" Value="SemiLight"/>
          </Style>
          <Style x:Key="CaptionTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}">
              <Setter Property="FontSize" Value="12"/>
              <Setter Property="Foreground" Value="{ThemeResource ApplicationSecondaryForegroundThemeBrush}"/>
          </Style>
          <Style x:Key="GroupHeaderTextStyle" TargetType="TextBlock">
              <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/>
              <Setter Property="TextTrimming" Value="WordEllipsis"/>
              <Setter Property="TextWrapping" Value="NoWrap"/>
              <Setter Property="Typography.StylisticSet20" Value="True"/>
              <Setter Property="Typography.DiscretionaryLigatures" Value="True"/>
              <Setter Property="Typography.CaseSensitiveForms" Value="True"/>
              <Setter Property="FontSize" Value="26.667"/>
              <Setter Property="LineStackingStrategy" Value="BlockLineHeight"/>
              <Setter Property="FontWeight" Value="Light"/>
              <Setter Property="LineHeight" Value="30"/>
              <Setter Property="RenderTransform">
                  <Setter.Value>
                      <TranslateTransform X="-1" Y="6"/>
                  </Setter.Value>
              </Setter>
          </Style>
          <!-- Button styles -->
          <!--
              TextButtonStyle is used to style a Button using subheader-styled text with no other adornment.  There
              are two styles that are based on TextButtonStyle (TextPrimaryButtonStyle and TextSecondaryButtonStyle)
              which are used in the GroupedItemsPage as a group header and in the FileOpenPickerPage for triggering
              commands.
          -->
          <Style x:Key="TextButtonStyle" TargetType="ButtonBase">
              <Setter Property="MinWidth" Value="0"/>
              <Setter Property="MinHeight" Value="0"/>
              <Setter Property="Template">
                  <Setter.Value>
                      <ControlTemplate TargetType="ButtonBase">
                          <Grid Background="Transparent">
                              <ContentPresenter x:Name="Text" Content="{TemplateBinding Content}" />
                              <Rectangle
                                  x:Name="FocusVisualWhite"
                                  IsHitTestVisible="False"
                                  Stroke="{ThemeResource FocusVisualWhiteStrokeThemeBrush}"
                                  StrokeEndLineCap="Square"
                                  StrokeDashArray="1,1"
                                  Opacity="0"
                                  StrokeDashOffset="1.5"/>
                              <Rectangle
                                  x:Name="FocusVisualBlack"
                                  IsHitTestVisible="False"
                                  Stroke="{ThemeResource FocusVisualBlackStrokeThemeBrush}"
                                  StrokeEndLineCap="Square"
                                  StrokeDashArray="1,1"
                                  Opacity="0"
                                  StrokeDashOffset="0.5"/>
                              <VisualStateManager.VisualStateGroups>
                                  <VisualStateGroup x:Name="CommonStates">
                                      <VisualState x:Name="Normal"/>
                                      <VisualState x:Name="PointerOver">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ApplicationPointerOverForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Pressed">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ApplicationPressedForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Disabled">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ApplicationPressedForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                  </VisualStateGroup>
                                  <VisualStateGroup x:Name="FocusStates">
                                      <VisualState x:Name="Focused">
                                          <Storyboard>
                                              <DoubleAnimation Duration="0" To="1" Storyboard.TargetName="FocusVisualWhite" Storyboard.TargetProperty="Opacity"/>
                                              <DoubleAnimation Duration="0" To="1" Storyboard.TargetName="FocusVisualBlack" Storyboard.TargetProperty="Opacity"/>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Unfocused"/>
                                  </VisualStateGroup>
                                  <VisualStateGroup x:Name="CheckStates">
                                      <VisualState x:Name="Checked"/>
                                      <VisualState x:Name="Unchecked">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ApplicationSecondaryForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Indeterminate"/>
                                  </VisualStateGroup>
                              </VisualStateManager.VisualStateGroups>
                          </Grid>
                      </ControlTemplate>
                  </Setter.Value>
              </Setter>
          </Style>
          <Style x:Key="MenuTextButtonStyle" TargetType="ButtonBase">
              <Setter Property="MinWidth" Value="0"/>
              <Setter Property="MinHeight" Value="0"/>
              <Setter Property="Template">
                  <Setter.Value>
                      <ControlTemplate TargetType="ButtonBase">
                          <Grid Background="Transparent">
                              <ContentPresenter x:Name="Text" Content="{TemplateBinding Content}" />
                              <Rectangle
                                  x:Name="FocusVisualWhite"
                                  IsHitTestVisible="False"
                                  Stroke="{ThemeResource FocusVisualWhiteStrokeThemeBrush}"
                                  StrokeEndLineCap="Square"
                                  StrokeDashArray="1,1"
                                  Opacity="0"
                                  StrokeDashOffset="1.5"/>
                              <Rectangle
                                  x:Name="FocusVisualBlack"
                                  IsHitTestVisible="False"
                                  Stroke="{ThemeResource FocusVisualBlackStrokeThemeBrush}"
                                  StrokeEndLineCap="Square"
                                  StrokeDashArray="1,1"
                                  Opacity="0"
                                  StrokeDashOffset="0.5"/>
                              <VisualStateManager.VisualStateGroups>
                                  <VisualStateGroup x:Name="CommonStates">
                                      <VisualState x:Name="Normal"/>
                                      <VisualState x:Name="PointerOver">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ApplicationPointerOverForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Pressed">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ApplicationPressedForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Disabled">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ApplicationPressedForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                  </VisualStateGroup>
                                  <VisualStateGroup x:Name="FocusStates">
                                      <VisualState x:Name="Focused">
                                          <Storyboard>
                                              <DoubleAnimation Duration="0" To="1" Storyboard.TargetName="FocusVisualWhite" Storyboard.TargetProperty="Opacity"/>
                                              <DoubleAnimation Duration="0" To="1" Storyboard.TargetName="FocusVisualBlack" Storyboard.TargetProperty="Opacity"/>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Unfocused"/>
                                  </VisualStateGroup>
                                  <VisualStateGroup x:Name="CheckStates">
                                      <VisualState x:Name="Checked"/>
                                      <VisualState x:Name="Unchecked">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ApplicationSecondaryForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Indeterminate"/>
                                  </VisualStateGroup>
                              </VisualStateManager.VisualStateGroups>
                          </Grid>
                      </ControlTemplate>
                  </Setter.Value>
              </Setter>
          </Style>
          <Style x:Key="TextPrimaryButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource TextButtonStyle}">
              <Setter Property="Foreground" Value="{ThemeResource ApplicationHeaderForegroundThemeBrush}"/>
          </Style>
          <Style x:Key="TextSecondaryButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource TextButtonStyle}">
              <Setter Property="Foreground" Value="{ThemeResource ApplicationSecondaryForegroundThemeBrush}"/>
          </Style>
          <!--
              TextRadioButtonStyle is used to style a RadioButton using subheader-styled text with no other adornment.
              This style is used in the SearchResultsPage to allow selection among filters.
          -->
          <Style x:Key="TextRadioButtonStyle" TargetType="RadioButton" BasedOn="{StaticResource TextButtonStyle}">
              <Setter Property="Margin" Value="0,0,30,0"/>
          </Style>
          <!--
              AppBarButtonStyle is used to style a Button (or ToggleButton) for use in an App Bar.  Content will be centered
              and should fit within the 40 pixel radius glyph provided.  16-point Segoe UI Symbol is used for content text
              to simplify the use of glyphs from that font.  AutomationProperties.Name is used for the text below the glyph.
          -->
          <Style x:Key="AppBarButtonStyle" TargetType="ButtonBase">
              <Setter Property="Foreground" Value="{ThemeResource AppBarItemForegroundThemeBrush}"/>
              <Setter Property="VerticalAlignment" Value="Stretch"/>
              <Setter Property="FontFamily" Value="Segoe UI Symbol"/>
              <Setter Property="FontWeight" Value="Normal"/>
              <Setter Property="FontSize" Value="20"/>
              <Setter Property="AutomationProperties.ItemType" Value="App Bar Button"/>
              <Setter Property="Template">
                  <Setter.Value>
                      <ControlTemplate TargetType="ButtonBase">
                          <Grid x:Name="RootGrid" Width="100" Background="Transparent">
                              <StackPanel VerticalAlignment="Top" Margin="0,12,0,11">
                                  <Grid Width="40" Height="40" Margin="0,0,0,5" HorizontalAlignment="Center">
                                      <TextBlock x:Name="BackgroundGlyph" Text="&#xE0A8;" FontFamily="Segoe UI Symbol" FontSize="53.333" Margin="-4,-19,0,0" Foreground="{ThemeResource AppBarItemBackgroundThemeBrush}"/>
                                      <TextBlock x:Name="OutlineGlyph" Text="&#xE0A7;" FontFamily="Segoe UI Symbol" FontSize="53.333" Margin="-4,-19,0,0"/>
                                      <ContentPresenter x:Name="Content" HorizontalAlignment="Center" Margin="-1,-1,0,0" VerticalAlignment="Center"/>
                                  </Grid>
                                  <TextBlock
                                      x:Name="TextLabel"
                                      Text="{TemplateBinding AutomationProperties.Name}"
                                      Foreground="{ThemeResource AppBarItemForegroundThemeBrush}"
                                      Margin="0,0,2,0"
                                      FontSize="12"
                                      TextAlignment="Center"
                                      Width="88"
                                      MaxHeight="32"
                                      TextTrimming="WordEllipsis"
                                      Style="{StaticResource BasicTextStyle}"/>
                              </StackPanel>
                              <Rectangle
                                      x:Name="FocusVisualWhite"
                                      IsHitTestVisible="False"
                                      Stroke="{ThemeResource FocusVisualWhiteStrokeThemeBrush}"
                                      StrokeEndLineCap="Square"
                                      StrokeDashArray="1,1"
                                      Opacity="0"
                                      StrokeDashOffset="1.5"/>
                              <Rectangle
                                      x:Name="FocusVisualBlack"
                                      IsHitTestVisible="False"
                                      Stroke="{ThemeResource FocusVisualBlackStrokeThemeBrush}"
                                      StrokeEndLineCap="Square"
                                      StrokeDashArray="1,1"
                                      Opacity="0"
                                      StrokeDashOffset="0.5"/>
                              <VisualStateManager.VisualStateGroups>
                                  <VisualStateGroup x:Name="ApplicationViewStates">
                                      <VisualState x:Name="FullScreenLandscape"/>
                                      <VisualState x:Name="Filled"/>
                                      <VisualState x:Name="FullScreenPortrait">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="Visibility">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                                              </ObjectAnimationUsingKeyFrames>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid" Storyboard.TargetProperty="Width">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="60"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Snapped">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="Visibility">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                                              </ObjectAnimationUsingKeyFrames>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid" Storyboard.TargetProperty="Width">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="60"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                  </VisualStateGroup>
                                  <VisualStateGroup x:Name="CommonStates">
                                      <VisualState x:Name="Normal"/>
                                      <VisualState x:Name="PointerOver">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemPointerOverBackgroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemPointerOverForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Pressed">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OutlineGlyph" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemPressedForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Disabled">
                                          <Storyboard>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OutlineGlyph" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemDisabledForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemDisabledForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemDisabledForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                  </VisualStateGroup>
                                  <VisualStateGroup x:Name="FocusStates">
                                      <VisualState x:Name="Focused">
                                          <Storyboard>
                                              <DoubleAnimation
                                                      Storyboard.TargetName="FocusVisualWhite"
                                                      Storyboard.TargetProperty="Opacity"
                                                      To="1"
                                                      Duration="0"/>
                                              <DoubleAnimation
                                                      Storyboard.TargetName="FocusVisualBlack"
                                                      Storyboard.TargetProperty="Opacity"
                                                      To="1"
                                                      Duration="0"/>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Unfocused" />
                                      <VisualState x:Name="PointerFocused" />
                                  </VisualStateGroup>
                                  <VisualStateGroup x:Name="CheckStates">
                                      <VisualState x:Name="Checked">
                                          <Storyboard>
                                              <DoubleAnimation Duration="0" To="0" Storyboard.TargetName="OutlineGlyph" Storyboard.TargetProperty="Opacity"/>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundCheckedGlyph" Storyboard.TargetProperty="Visibility">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                              </ObjectAnimationUsingKeyFrames>
                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content" Storyboard.TargetProperty="Foreground">
                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemPressedForegroundThemeBrush}"/>
                                              </ObjectAnimationUsingKeyFrames>
                                          </Storyboard>
                                      </VisualState>
                                      <VisualState x:Name="Unchecked"/>
                                      <VisualState x:Name="Indeterminate"/>
                                  </VisualStateGroup>
                              </VisualStateManager.VisualStateGroups>
                          </Grid>
                      </ControlTemplate>
                  </Setter.Value>
              </Setter>
          </Style>
          <!--
              Standard AppBarButton Styles for use with Button and ToggleButton
       
              An AppBarButton Style is provided for each of the glyphs in the Segoe UI Symbol font.
              Uncomment any style you reference (as not all may be required).
          -->
          <Style x:Key="CopyAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
              <Setter Property="AutomationProperties.AutomationId" Value="CopyAppBarButton"/>
              <Setter Property="AutomationProperties.Name" Value="Copy"/>
              <Setter Property="Content" Value="&#xE16F;"/>
          </Style>
          <Style x:Key="PasteAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
              <Setter Property="AutomationProperties.AutomationId" Value="PasteAppBarButton"/>
              <Setter Property="AutomationProperties.Name" Value="Paste"/>
              <Setter Property="Content" Value="&#xE16D;"/>
          </Style>
          <Style x:Key="CutAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
              <Setter Property="AutomationProperties.AutomationId" Value="CutAppBarButton"/>
              <Setter Property="AutomationProperties.Name" Value="Cut"/>
              <Setter Property="Content" Value="&#xE16B;"/>
          </Style>
          <Style x:Key="UnderlineAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
              <Setter Property="AutomationProperties.AutomationId" Value="UnderlineAppBarButton"/>
              <Setter Property="AutomationProperties.Name" Value="Underline"/>
              <Setter Property="Content" Value="&#xE19A;"/>
          </Style>
          <Style x:Key="BoldAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
              <Setter Property="AutomationProperties.AutomationId" Value="BoldAppBarButton"/>
              <Setter Property="AutomationProperties.Name" Value="Bold"/>
              <Setter Property="Content" Value="&#xE19B;"/>
          </Style>
          <Style x:Key="ItalicAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
              <Setter Property="AutomationProperties.AutomationId" Value="ItalicAppBarButton"/>
              <Setter Property="AutomationProperties.Name" Value="Italic"/>
              <Setter Property="Content" Value="&#xE199;"/>
          </Style>
          <Style x:Key="MoreAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
              <Setter Property="AutomationProperties.AutomationId" Value="MoreAppBarButton"/>
              <Setter Property="AutomationProperties.Name" Value="More"/>
              <Setter Property="Content" Value="&#xE10C;"/>
          </Style>
          <Style x:Key="RedoAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
              <Setter Property="AutomationProperties.AutomationId" <Setter Property="AutomationProperties.Name" Value="Align Right"/>
              <Setter Property="Content" Value="&#xE1A0;"/>
          </Style>
      </ResourceDictionary>
  2. アプリケーション名を再度右クリックし、[追加]→[新しいフォルダ]を選択します。新しいフォルダ名を Resources と指定します。
    1. Resources フォルダを右クリックし、[追加]→[新しい項目]を選択します。
    2. [新しい項目の追加] ダイアログウィンドウの利用可能なテンプレートから[HTML ページ]を選択します。新しいファイルに simple.htm と名前を付けます。
    3. 空白ページが開いたら、次のマークアップを追加します。

      XAML でマークアップの書き方

      XAML マークアップ
      コードのコピー
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <html>
      <body style="font-size:medium">
          <p>
              Display and edit formatted text as HTML documents with <strong> RichTextBox<span style="font-size:x-small"><sup>TM</sup></span> for WinRT XAML</strong>. Use the control to display HTML content from the Web or use it as a rich text editor. The <strong>C1RichTextBox</strong> control supports:
          </p>
          <ul style="line-height:1.5em">
              <li>
                  &nbsp;Most text <span style="background-color: yellow"><strong>decorations</strong></span>, <span style="color: red"><em>alignments</em></span> and <u>styles</u>
              </li>
              <li>
                  &nbsp;Bulleted and numbered lists
              </li>
              <li>
                  &nbsp;Clipboard and document history (undo and redo)
              </li>
              <li>
                  &nbsp;Hyperlinks: <a href="http://www.componentone.com">ComponentOne website</a>
              </li>
              <li>
                  &nbsp;Insert tables and pictures
              </li>
          </ul>
      </body>
      </html>
    4. ソリューションエクスプローラーで simple.htm を選択します。[プロパティ]ウィンドウで、[ビルドアクション][埋め込みリソース]に設定します。
    5. アプリケーションをリビルドします。
  3. ソリューションエクスプローラーで App.xaml ファイルをダブルクリックし、次のマークアップを追加します。
    XAML
    コードのコピー
    <Application.Resources>
      <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
         <!-- Styles that define common aspects of the platform look and feel required by Visual Studio project and item templates -->
               <ResourceDictionary Source="Common/StandardStyles.xaml"/>
             </ResourceDictionary.MergedDictionaries>
           </ResourceDictionary>
        </Application.Resources>

この手順では、アプリケーションリソースのコンテンツを追加および設定し、これらのリソースをアプリケーション全体に適用するためのマークアップを追加しました。次の手順では、いくつかの AppBar 項目の汎用コードと、最初の手順で追加した C1RichTextBox イベントを処理する汎用コードを追加します。