zoukankan      html  css  js  c++  java
  • WPF Demo8

    namespace Demo10
    {
        public class Student
        {
            private string name;
    
            public string Name
            {
                get { return name; }
                set { name = value; }
            }
        }
    }
    

      

    <Window x:Class="Demo10.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <StackPanel>
            <TextBlock Margin="5" Text="Student Name:"/>
            <TextBox Margin="5" x:Name="txtName"/>
            
            <TextBlock Margin="5" Text="Student List:"/>
            <ListBox Margin="5" x:Name="lsbList"/>
        </StackPanel>
    </Window>
    using System.Collections.Generic;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    
    namespace Demo10
    {
        /// <summary>
        /// MainWindow.xaml 的交互逻辑
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
    
                List<Student> stuList = new List<Student>()
                {
                    new Student(){Name ="Tim"},
                    new Student(){Name ="Tom"},
                    new Student(){Name ="JIM"},
                    new Student(){Name ="Kite"},
                    new Student(){Name ="quanquan"},
                };
    
                this.lsbList.ItemsSource = stuList;
                this.lsbList.DisplayMemberPath = "Name";
    
                Binding binding = new Binding("SelectedItem.Name") { Source=this.lsbList};
                this.txtName.SetBinding(TextBox.TextProperty,binding);
            }
        }
    }
    

  • 相关阅读:
    mysql 查询优化
    图解Java常用数据结构(一)
    mybatis 详解(五)------动态SQL
    Mybatis的ResultMap的使用
    java系统变慢的优化简略步骤
    mysql基本操作
    mysql数据库的优化 一
    tomcat的启动启动与关闭
    vueJs的简单入门以及基础语法
    Oracle常用命令-用户、表空间、赋权限、导入导出
  • 原文地址:https://www.cnblogs.com/YYkun/p/6867244.html
Copyright © 2011-2022 走看看