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>

效果图如下

相关推荐
Zhen (Evan) Wang3 分钟前
WPF常用技巧汇总 - Part 2
java·大数据·wpf
冰茶_9 小时前
WPF之TextBlock控件详解
microsoft·微软·c#·wpf·wpf控件
冰茶_14 小时前
WPF之Button控件详解
大数据·学习·microsoft·c#·wpf
CoderIsArt14 小时前
WPF 程序监控硬件设备状态变化的实现方案
windows·wpf
冰茶_21 小时前
WPF TextBlock控件性能优化指南
学习·性能优化·wpf·控件
code bean2 天前
【wpf】 WPF中实现动态加载图片浏览器(边滚动边加载)
wpf
baivfhpwxf20232 天前
WPF 颜色间的转换 Color,Brush
wpf
Java Fans2 天前
WPF使用SQLite与JSON文本文件结合存储体侧平衡数据的设计与实现
sqlite·json·wpf
code_shenbing2 天前
WPF高级用法示例
c#·wpf·wpf高级
冰茶_2 天前
WPF之XAML基础
microsoft·微软·c#·.net·wpf·xaml·xamarin