基礎控件:<TextBlock Text="添加文字"
FontFamily=" 字體
"FontSize=" 字號"
FontWeight="設置文本粗細"
Foreground="前景色(字體顏色)"
TextAlignment="文本內容的水平對齊方式,默認值為left"
TextTrimming="獲取或設置在內容超出內容區域時要采用的文本剪裁行為,默認值為None">
</TextBlock>
代碼如下:
<Window x:Class="WPFextControl.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:WPFextControl" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525"> <StackPanel > <TextBlock Text=" WPF TextBlock" FontFamily=" 宋體" FontSize=" 16" FontWeight="Bold" Foreground="Red" TextWrapping="NoWrap" TextAlignment="Center" ></TextBlock> <TextBlock Text="北方的春晨,依舊寒涼,緊緊地把體溫拽在手心,阡陌荒涼,靜默無聲,我開始情不自禁幻想南國風情,應是花草叢叢,細雨蒙蒙。傘花美麗了巷陌,青階,誰撐一把素潔的白傘,痴目遠眺,一懷溫情。而我的江北終究無法飛越你的江南,冷寒,籠袖。" FontFamily=" 宋體" FontSize=" 16" FontWeight="Bold" Foreground="Red" TextAlignment="Left" TextTrimming="CharacterEllipsis" ></TextBlock> <TextBlock Text="Muslims have been leaving Buddhist-majority Myanmar, also known as Burma, because they are not recognised as citizens of the country and face persecution. Many of the Bangladeshis at sea are thought to be economic migrants." FontFamily=" 宋體" FontSize=" 16" FontWeight="Bold" Foreground="Red" TextAlignment="Left" TextTrimming="WordEllipsis" ></TextBlock> <TextBlock Text="Muslims have been leaving Buddhist-majority Myanmar, also known as Burma, because they are not recognised as citizens of the country and face persecution. Many of the Bangladeshis at sea are thought to be economic migrants." FontFamily=" 宋體" FontSize=" 16" FontWeight="Bold" Foreground="Red" TextAlignment="Left" TextTrimming="CharacterEllipsis" ></TextBlock> <local:MyTextBox Loaded="MyTextBox_Loaded"></local:MyTextBox> </StackPanel > </Window>
