title: Define the FontFamily as a resource in Windows Phone
body: <p>It's a little strange that after defining the FontFamily for the TextBox in the App.xaml, nothing changed. The code is </p>
  
  <pre><code>&lt;Style TargetType="TextBox"&gt;
          &lt;Setter Property="FontFamily" Value="Fonts/WenQuanYiMicroHei.ttf#WenQuanYiMicroHei"/&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p>When changing the TargetType into "TextBlock", the TextBlock will change its fontfamily.</p>
  
  <p>Besides, I've also define a style for the TextBock like:</p>
  
  <pre><code>&lt;Style x:Key="TextBoxStyle4FF" TargetType="TextBox"&gt;
          &lt;Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/&gt;
          &lt;Setter Property="Background" Value="Transparent"/&gt;
          &lt;Setter Property="Foreground" Value="White"/&gt;
          &lt;Setter Property="BorderBrush" Value="White"/&gt;
          &lt;Setter Property="SelectionBackground" Value="{StaticResource PhoneAccentBrush}"/&gt;
          &lt;Setter Property="SelectionForeground" Value="{StaticResource PhoneTextBoxSelectionForegroundBrush}"/&gt;
          &lt;Setter Property="BorderThickness" Value="2"/&gt;
          &lt;Setter Property="Padding" Value="0"/&gt;
          &lt;Setter Property="CaretBrush" Value="White"/&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="TextBox"&gt;
                      &lt;Grid Background="Transparent"&gt;
                          &lt;VisualStateManager.VisualStateGroups&gt;
                              &lt;VisualStateGroup x:Name="CommonStates"&gt;
                                  &lt;VisualState x:Name="Normal"/&gt;
                                  &lt;VisualState x:Name="MouseOver"/&gt;
                                  &lt;VisualState x:Name="Disabled"&gt;
                                  &lt;/VisualState&gt;
                                  &lt;VisualState x:Name="ReadOnly"&gt;
                                  &lt;/VisualState&gt;
                              &lt;/VisualStateGroup&gt;
                              &lt;VisualStateGroup x:Name="FocusStates"&gt;
                                  &lt;VisualState x:Name="Focused"&gt;
                                      &lt;Storyboard&gt;
                                          &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="EnabledBorder"&gt;
                                              &lt;DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/&gt;
                                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                                          &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="EnabledBorder"&gt;
                                              &lt;DiscreteObjectKeyFrame KeyTime="0" Value="White"/&gt;
                                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                                      &lt;/Storyboard&gt;
                                  &lt;/VisualState&gt;
                                  &lt;VisualState x:Name="Unfocused"/&gt;
                              &lt;/VisualStateGroup&gt;
                          &lt;/VisualStateManager.VisualStateGroups&gt;
                          &lt;Border x:Name="EnabledBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Margin="0"&gt;
                              &lt;ContentControl x:Name="ContentElement" BorderThickness="0" HorizontalContentAlignment="Stretch" Margin="{StaticResource PhoneTextBoxInnerMargin}" Padding="0" VerticalContentAlignment="Stretch" FontFamily="{TemplateBinding FontFamily}"/&gt;
                          &lt;/Border&gt;
                          &lt;Border x:Name="DisabledOrReadonlyBorder" BorderBrush="{StaticResource PhoneDisabledBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" Margin="{StaticResource PhoneTouchTargetOverhang}" Visibility="Collapsed"&gt;
                              &lt;TextBox x:Name="DisabledOrReadonlyContent" Background="Transparent" Foreground="{StaticResource PhoneDisabledBrush}" FontWeight="{TemplateBinding FontWeight}" FontStyle="{TemplateBinding FontStyle}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" IsReadOnly="True" SelectionForeground="{TemplateBinding SelectionForeground}" SelectionBackground="{TemplateBinding SelectionBackground}" TextAlignment="{TemplateBinding TextAlignment}" TextWrapping="{TemplateBinding TextWrapping}" Text="{TemplateBinding Text}" Template="{StaticResource PhoneDisabledTextBoxTemplate}"/&gt;
                          &lt;/Border&gt;
                      &lt;/Grid&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p>Is it because the Style definition for the TextBox?</p>
  
  <p>So I decided to define a FontFamily Resource for the TextBox, but couldn't find a way to define the FontFamily. It seems that the FontFamily is in the <code>System.Windows.Media</code> namespace, but adding this namespace  <code>xmlns:media="clr-namespace:System.Windows.Media;assembly=System.Windows"</code> is useless.</p>
  
  <p>Any reply is appreciated.</p>