WPF的TextBlock控件

WPF的TextBlock控件

在这里插入图片描述
XMAL代码如下:

<Window x:Class="MyControl.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:MyControl"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="500">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <TextBlock Margin="10" Foreground="Red" Grid.Row="0" HorizontalAlignment="Center" FontSize="20">
            This is a textblock control<LineBreak/>
            this is second line
        </TextBlock>
        <TextBlock Margin="10" Foreground="Green" Grid.Row="1" HorizontalAlignment="Left">
            This is a TextBlock control with text that may not be rendered completely, which will be indicated with an ellipsis.
        </TextBlock>
        <TextBlock Grid.Row="2" TextWrapping="Wrap" Foreground="Blue">
            This is a TextBlock control with automatically wrapped text, using the TextWrapping property.
        </TextBlock>
        <TextBlock Grid.Row="3" TextWrapping="Wrap" Foreground="Black">
            <Bold>this is a bold line</Bold><LineBreak/>
            <Italic>this is a  italic line</Italic><LineBreak/>
            <Underline>this is a underLine word</Underline><LineBreak/>
            <Hyperlink  RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="https://www.baidu.com">Click me to navigate to Baidu</Hyperlink>
        </TextBlock>
        <TextBlock Grid.Row="4">
            This <Span FontWeight="Bold" FontSize="20" Foreground="Blue">is</Span>
            a <Span FontSize="10" TextDecorations="Underline">line</Span>
            using <Span FontStyle="Italic" FontSize="15" Foreground="Red">custom</Span> span !
        </TextBlock>
        </Grid>
</Window>

参考文章

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值