<Button x:Name="btn"
Content="退出"
Width=" 100"
Height="25"
Click="btn_Click" IsDefault="True"/>
<Button x:Name="btn" <!-- 控件标识:定义按钮的实例名称为"btn",用于后台代码(如C#)中引用该控件 -->
Content="退出" <!-- 显示文本:设置按钮上显示的文本内容为"退出" -->
Width=" 100" <!-- 控件宽度:设置按钮宽度为100设备无关单位(注意值前空格会被XAML自动忽略) -->
Height="25" <!-- 控件高度:设置按钮高度为25设备无关单位 -->
Click="btn_Click" <!-- 事件绑定:将按钮的点击事件关联到后台代码中的btn_Click方法 -->
IsDefault="True"/> <!-- 默认行为:设置该按钮为窗口默认按钮,用户按Enter键时会自动触发点击事件 -->
<WrapPanel>
<TextBlock Text="这是一个TextBlock文字块" Margin="5"/>
<TextBlock Text="粗体文字" FontWeight="Bold" Margin="5"/>
<TextBlock Text="粗体文字" FontWeight="Light" Margin="5"/>
<TextBlock Text="斜体文字" FontStyle="Italic" Margin="5"/>
<TextBlock Text="微软雅黑" FontFamily="Microsoft YaHei UI" Margin="5"/>
<TextBlock Text="大号字体" Foreground="Red" Margin="5"/>
<TextBlock Text="红色文字" Foreground="Yellow" Margin="5"/>
<TextBlock Text="底色文字" Foreground="Yellow" Background="Red" Margin="5"/>
<TextBlock Background="LightGray" Height="25">
<Run Foreground="Red">这行文字</Run>
<Run Foreground="Green">由三部分</Run>
<Run Foreground="Blue">组成</Run>
</TextBlock>
<Grid Width="150" Height="100" Margin="5" Background="LightGoldenrodYellow">
<TextBlock Text="这段文字体现了文字的文本换行属性TextWrapping" TextWrapping="Wrap" Margin="10"/>
</Grid>
<!--使用Run-->
<Grid>
<TextBlock x:Name="txtBlock"
Width="320"
Height="100"
FontSize="15"
FontFamily="微软雅黑"
FontWeight="Black"
FontStretch="Condensed"
Foreground="#dddddd"
Background="Teal"
TextAlignment="Center"
TextWrapping="Wrap"
TextTrimming="CharacterEllipsis"
Margin="10" Padding="5"
HorizontalAlignment="Left"
VerticalAlignment="Center"
LineHeight="30"
ToolTip="《临江仙·滚滚长江东逝水》">
<Run Foreground="#CDB632" T