WPF —— TextBlock、LineBreak RadioButton控件详解

一:TextBlock

1:TextBlock 简介

<LineBreak/> 换行

显示文本 标签内容和content属性共存

2、TextBlock 常用的属性

Foreground:TextBlock的文本内容的颜色。

Background:背景,获取或设置要用于填充内容区域背景的 Brush。

FontFamily:获取或设置 TextBlock 的首选最常用字体系列。

FontSize:TextBlock的字体大小。

FontStretch:获取或设置 TextBlock 的常用字体拉伸特征。

FontStyle:获取或设置 TextBlock 的顶级字体样式。

3 关于 TextBlock、LineBreak的实例

cs 复制代码
<TextBlock Text="青海洪水" FontSize="40" FontWeight="Bold" Foreground="Red">
    <LineBreak/>你好
    <LineBreak/>娃哈哈领导人去世了
    <LineBreak/>比亚迪秦15万左右,新款和比亚迪秦一样,
    <LineBreak/>但是价格七八万
</TextBlock>

二 :RadioButton单选框

实现分组的单选框,可以通过一下几种方式进行分组

1 通过groupName设置相同值进行分组

2 通过把单选框添加一个相同父标签

关于RadioButton的实例

cs 复制代码
        <RadioButton  GroupName="sex" Content="男" FontSize="20" Foreground="blue"
                      VerticalContentAlignment="Center" Width="100" Height="40"
                      HorizontalAlignment="Left" VerticalAlignment="top" 
                      >
        </RadioButton>
        <RadioButton  GroupName="sex" Content="女" FontSize="20" Foreground="blue"
               VerticalContentAlignment="Center" Width="100" Height="40"
               HorizontalAlignment="Left" VerticalAlignment="top" Margin="110,0"
               >
        </RadioButton>
        <RadioButton  GroupName="sex" Content="中" FontSize="20" Foreground="blue"
               VerticalContentAlignment="Center" Width="100" Height="40"
               HorizontalAlignment="Left" VerticalAlignment="top"  Margin="220,0"
               IsChecked="True"      
               >
        </RadioButton>
        <Grid Name="g2">
            <RadioButton   Content="苹果" FontSize="20" Foreground="blue"
         VerticalContentAlignment="Center" Width="261" Height="40"
         HorizontalAlignment="Left" VerticalAlignment="Top"  Margin="0,50,0,0"
         
         >
            </RadioButton>
            <RadioButton   Content="香蕉" FontSize="20" Foreground="blue"
VerticalContentAlignment="Center" Width="472" Height="40"
HorizontalAlignment="Left" VerticalAlignment="Top"  Margin="318,50,0,0"
IsChecked="True"      
>
            </RadioButton>

        </Grid>
        <Button Width="100" Height="40" Content="点击获取" Click="Button_Click">
        </Button>

效果图如下

相关推荐
武藤一雄9 小时前
.NET 中常见计时器大全
microsoft·微软·c#·.net·wpf·.netcore
MarkHD13 小时前
车辆TBOX科普 第70次 AUTOSAR Adaptive、容器化与云原生的融合革命
云原生·wpf
极客智造14 小时前
WPF Behavior 实战:自定义 InvokeCommandAction 实现事件与命令解耦
wpf
L、21814 小时前
Flutter 与 OpenHarmony 深度集成:构建分布式多端协同应用
分布式·flutter·wpf
布伦鸽14 小时前
C# WPF -MaterialDesignTheme 找不到资源“xxx“问题记录
开发语言·c#·wpf
小二·1 天前
MyBatis基础入门《十五》分布式事务实战:Seata + MyBatis 实现跨服务数据一致性
分布式·wpf·mybatis
helloworddm1 天前
UnregisterManyAsync
wpf
军训猫猫头1 天前
3.NModbus4 长距离多设备超时 C# + WPF 完整示例
c#·.net·wpf·modbus
Aevget2 天前
DevExpress WPF中文教程:Data Grid - 如何绑定到有限制的自定义服务(一)?
ui·.net·wpf·devexpress·ui开发·wpf界面控件
Macbethad2 天前
半导体设备工厂自动化软件技术方案
wpf·智能硬件