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);
            }
        }
    }
    

  • 相关阅读:
    多线程编程核心技术(五)死锁
    SELinux详细配置
    Linux实现RAID
    iSCSi的基本配置
    文本超出省略号之前后省略号实现
    对象冻结
    条件判断的优美写法
    使用VConsole
    重绘和重排(回流)
    移动端rem布局
  • 原文地址:https://www.cnblogs.com/YYkun/p/6867244.html
Copyright © 2011-2022 走看看