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>

效果图如下

相关推荐
Aevget34 分钟前
界面控件DevExpress WPF v25.1新版亮点:PDF Viewer功能全新升级
pdf·wpf·界面控件·devexpress·ui开发
5***a9752 天前
后端配置中心选型,Nacos与Apollo
wpf
·心猿意码·2 天前
WPF转换器机制
wpf
她说彩礼65万2 天前
WPF命令
wpf
玖笙&2 天前
✨WPF编程进阶【7.3】集成动画(附源码)
c++·c#·wpf·visual studio
ifeng09182 天前
鸿蒙分布式调试挑战:跨设备数据流转与连接稳定性
分布式·wpf·harmonyos
Macbethad2 天前
如何使用WPF做工控主页
wpf
Aevget2 天前
DevExpress WPF中文教程:Data Grid - Service(服务)示例
wpf·界面控件·devexpress·ui开发
Macbethad3 天前
WPF工控软件的设计方案
wpf
Macbethad5 天前
使用WPF编写一个读取串口的程序
wpf