WPF值textbox输入框

在wpf中textbox标签代表输入盒子。

常用属性

|----------------|---------|
| SelectionBrush | 选定文本的颜色 |
| BorderBrush | 边框颜色 |
| fontsize | 文本大小 |
| Foreground | 字体颜色 |

事件

|-------------|---------------|
| TextChanged | 输入框发生变化时触发的事件 |

实例:

功能: 设置输入框发生变化获取文本内容

cs 复制代码
<Grid>
    <!--SelectionBrush 选定的文本的颜色-->
    <!--TextChanged 输入框发生变化时触发的事件-->
    <Label Width="100" Height="40" BorderThickness="1" BorderBrush="Black"
    Margin="0,0,0,120" VerticalContentAlignment="Center" FontSize="15"
   Name="label" Content="label" 
   />
    <TextBox Name="text" Width="200" Height="40"
             BorderBrush="Black" BorderThickness="1"
             Text="请输入" VerticalContentAlignment="Center"
             FontSize="20" FontFamily="楷体"
             FontWeight="Light" FontStyle="Oblique"
             Foreground="Gray" SelectionBrush="Pink"
             TextChanged="f1" 
             >
    </TextBox>
    <Button Width="200" Height="100"
            HorizontalAlignment="Right"
            Content="点击获取选中文本内容"
            Click="f2" />
</Grid>



CS后台代码
// 输入框内容变化事件
private void f1(object sender, TextChangedEventArgs e)
{
    label.Content = this.text.Text;
}
相关推荐
dalong1018 小时前
WPF:箭头绘制程序
wpf·自定义绘制
张工在路上1 天前
WPF 布局基础概述
大数据·hadoop·wpf
迪飞特科技3 天前
分布式事务下 Spring 声明式事务失效的 3 种修复方案
分布式·spring·wpf
2601_962174175 天前
Redis 简介
数据库·redis·wpf
SamChan907 天前
Python+PyMuPDF提取PDF表格并翻译:表格结构检测与双语重建实战
windows·python·ai·pdf·wpf
SamChan907 天前
Python+OpenCV检测PDF翻译后排版偏移:像素级格式一致性验证
python·opencv·ai·pdf·wpf
FuckPatience7 天前
WPF 拿到控件的最初样式,修改获得焦点样式
wpf
主宰者7 天前
【WPF】MainWindow前添加加载窗口,发现加载过程中有白色无内容窗口闪烁一下的解决方案
wpf
Vae_Mars8 天前
WPF中的ControlTemplate(控件模板)
wpf
SamChan908 天前
Python+ReportLab自动生成PDF翻译质量审计报告:从数据到可视化的完整方案
开发语言·python·ai·pdf·wpf