Style assignment in the axml file
  <TextBlock Hello" Style="{StaticResource MyTextBlockStyleName}" />
Style definition if in App.xaml
        <Style x:Key="MyTextBlockStyleName" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="Arial"/>
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="FontSize" Value="18"/>
            <Setter Property="Height" Value="24"/>
        </Style>

It needs to be in a Application.Resources section, like this:

<Application
    x:Class="MyApp.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyApp"
    RequestedTheme="Light">

    <Application.Resources>
        <Style x:Key="MyTextBlockStyleName" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="Arial"/>
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="FontSize" Value="18"/>
            <Setter Property="Height" Value="24"/>
        </Style>
        
        Other styles...
        
    </Application.Resources>

</Application>
Style definition if in the axml file

Typically placed before the <grid>

<ContentDialog.Resources>
    <Style x:Key="MyTextBlockStyleName" TargetType="TextBlock">
        <Setter Property="FontFamily" Value="Arial"/>
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="FontSize" Value="18"/>
        <Setter Property="Height" Value="24"/>
    </Style>
</ContentDialog.Resources>
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *