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

    xaml:

    <Window x:Class="WpfApplication1.Window3"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="Window3" Height="300" Width="300">
        <StackPanel Height="229" Name="stackPanel1" Width="252">
            <TextBox Height="23" Name="textBox1" Width="120" Margin="10" />
            <TextBox Height="23" Name="textBox2" Width="120" Margin="10" />
            <TextBox Height="23" Name="textBox3" Width="120" Margin="10" />
        </StackPanel>
    </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>
        /// Window3.xaml 的交互逻辑
        /// </summary>
        public partial class Window3 : Window
        {
            public Window3()
            {
                InitializeComponent();
                List<string> infos = new List<string>() { "Jim","Darren","Jacky"};
                textBox1.SetBinding(TextBox.TextProperty, new Binding("/") { Source=infos});
                textBox2.SetBinding(TextBox.TextProperty, new Binding("/[2]") { Source = infos, Mode= BindingMode.OneWay });
                textBox3.SetBinding(TextBox.TextProperty, new Binding("/Length") { Source = infos, Mode= BindingMode.OneWay });
            }
        }
    }
  • 相关阅读:
    MFC中实现LISTCRTL控件选中多行进行删除操作
    如何使属性值为“只读”(readonly)的EDIT控件在获取焦点后不显示光标?
    crm 使用stark组件
    ModelForm组件
    自定义admin管理工具(stark组件)
    Django-admin管理工具
    Django-session中间件源码简单分析
    基于角色的权限管理
    ajax参数补充
    datetime模块
  • 原文地址:https://www.cnblogs.com/zwzw/p/3321061.html
Copyright © 2011-2022 走看看