WPF 标题字体显示
一、简单阴影
<Grid Background="AliceBlue">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel.Effect>
<DropShadowEffect Color="LightGray"/>
</StackPanel.Effect>
<TextBlock Text="君子务本,本立而道生。" FontSize="60" FontFamily="LiShu"/>
</StackPanel>
</Grid>
效果:
二、简单阴影
<Grid>
<TextBlock Name="copor" FontSize="36" Text="前车之覆,后车之鉴" HorizontalAlignment="Center" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" FontWeight="ExtraBold" >
<TextBlock.Effect>
<DropShadowEffect Color="#464646" BlurRadius="2" ShadowDepth="2" Opacity="1" />
</TextBlock.Effect>
<TextBlock.Foreground>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.0" Color="#ffffff" />
<GradientStop Offset="1.0" Color="#b7b7b7" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</TextBlock.Foreground>
</TextBlock>
</Grid>
效果:
三、颜色渐变
<StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" >
<StackPanel.Resources>
<Style x:Key="textBlockStyle" TargetType="TextBlock">
<!--字体渐变-->
<Setter Property="Foreground">
<Setter.Value>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,0.5">
<GradientStop Color="#FFFFE787" Offset="0.0" />
<!--<GradientStop Color="#FFFFE787" Offset="0.25" />-->
<GradientStop Color="White" Offset="0.5" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
<!--字体阴影-->
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect Color="Black" Direction="120" ShadowDepth="1" Opacity="0.7" />
</Setter.Value>
</Setter>
<Setter Property="FontFamily" Value="Microsoft YaHei"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontSize" Value="28"/>
</Style>
</StackPanel.Resources>
<TextBlock x:Name="tbl_OrganName" Margin="10,0,0,0" Text="" Style="{StaticResource textBlockStyle}" />
<TextBlock x:Name="tbl_SysName" Text="读书破万卷,下笔如有神。" Style="{StaticResource textBlockStyle}" />
</StackPanel>
效果: