WPF 绑定二(绑定指定的字符串)
2024-08-26 13:02:36
xaml:
<Window x:Class="WpfApplication1.Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window2" Height="345" Width="478">
<Grid>
<TextBox Height="23" HorizontalAlignment="Left" Margin="152,50,0,0" Name="textBox1" VerticalAlignment="Top" Width="158" Text="ABCDE" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="152,105,0,0" Name="textBox2" Text="{Binding Path=Text.[3],ElementName=textBox1,Mode=OneWay}" VerticalAlignment="Top" Width="158"/>
</Grid>
</Window>
cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes; namespace WpfApplication1
{
/// <summary>
/// Window2.xaml 的交互逻辑
/// </summary>
public partial class Window2 : Window
{
public Window2()
{
InitializeComponent();
//this.textBox2.SetBinding(TextBox.TextProperty, new Binding("Text.Length") {Source = textBox1, Mode= BindingMode.OneWay });
this.textBox2.SetBinding(TextBox.TextProperty, new Binding("Text.[3]") { Source=textBox1,Mode= BindingMode.OneWay});
}
}
}
最新文章
- Java的Json解析包FastJson使用
- Objective-C 快速入门--基础(五)
- html中a标签做容器的问题
- java读取properties配置文件方法(一)
- Java Phaser
- openstack 实例迁移
- HDU 5810 Balls and Boxes (找规律)
- HDOJ(HDU) 2136 Largest prime factor(素数筛选)
- 复数类(C++练习一)
- 6_StopWatch
- [补档]暑假集训D3总结
- 02-移动端开发教程-CSS3新特性(中)
- 安装nodejs中遇到的问题
- Thymeleaf 3.0 专题
- 浅析HTTP代理原理--转
- 二十三、Spring框架的相关知识点总结
- sql 中有关时间的语句
- Jmeter接口测试(八)cookie设置
- Sublime Text自定义插入当前时间的插件
- Linq编译带来的诡异错误
热门文章
- A标签使用javascript:伪协议
- IIS错误日志:Failed to execute request because the App-Domain
- 解决java中对URL编码的问题
- How to setup ELM327 Bluetooth WiFi for Android software Torque
- CentOS6.5 64bit 运行Mono程序
- Flask-在浏览器中直接显示文本文件中的内容
- 添加iPhone设备的udid之后,重新生成开发证书(Development)
- 深入浅出ExtJS 第七章 弹出窗口
- 在sql-server上建立mysql链接库
- C# 操作 Excel 常见问题收集和整理(定期更新,欢迎交流)