zoukankan      html  css  js  c++  java
  • WPF 绑定二(绑定指定的字符串)

    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});
            }
        }
    }
  • 相关阅读:
    Android一些问题
    内存泄漏(Memory Leak)
    内存溢出OOM
    Android面试题集合
    Handler之同步屏障机制(sync barrier)
    IdleHandler 原理浅析
    OkHttp原理
    RxJava操作符
    Android电量优化全解析
    Android内存优化大盘点
  • 原文地址:https://www.cnblogs.com/zwzw/p/3321059.html
Copyright © 2011-2022 走看看