WPF用户控件批量数据绑定

author: JimStone
date: 2015/9/17 6:29

用户控件(UserControl2.xaml)


    
        

主界面(MainWindow.xaml)


    
        
            
            
                
                    
                
            
            
            
                
                    
                    
                
            
        
    

主界面代码(MainWindow.xaml.cs)


    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        public class User
        {
            public string Name
            {
                get;
                set;
            }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            BindingList ul = new BindingList {
                new User { Name = "Boy" },
                new User { Name = "Girl" },
                new User { Name = "JimStone" }
            };
            this.ListItems.ItemsSource = ul;
        }
    }

你可能感兴趣的:(WPF用户控件批量数据绑定)