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>

效果图如下

相关推荐
code bean1 天前
【WPF】WPF 自定义控件之依赖属性
wpf
上元星如雨1 天前
WPF 加载和显示 GIF 图片的完整指南
wpf
微小冷2 天前
WPF中ListView控件详解
c#·wpf·数据绑定·listview·bingding
专注VB编程开发20年3 天前
WPF,Winform,HTML5网页,哪个UI开发速度最快?
大数据·c#·wpf
YANQ6623 天前
3.1 WPF画折线图、直方图、饼状图
wpf
上元星如雨3 天前
WPF demo:全屏加载界面
wpf
深漂阿碉3 天前
WPF自定义日历选择控件
wpf
六点的晨曦3 天前
WPF的三轴机械手控件动画
wpf
军训猫猫头4 天前
5.浏览本地文件获取路径与文件名称 C#例子 WPF例子
开发语言·c#·wpf
步、步、为营4 天前
.NET + WPF框架开发聊天、网盘、信息发布、视频播放功能
.net·wpf·音视频