首页 > Windows开发 > 详细

WPF Demo17 数据绑定

时间:2017-05-18 14:37:59      阅读:384      评论:0      收藏:0      [点我收藏+]

实例一:以资源的形式实现

技术分享

namespace 数据绑定1
{
    public class Student
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int Age { get; set; }
    }
}
<Window x:Class="数据绑定1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:数据绑定1"  
        Title="MainWindow" Height="350" Width="525">
    <StackPanel Background="LightBlue">
        <StackPanel.DataContext>
            <local:Student Id="6" Age="29" Name="Time"/>
        </StackPanel.DataContext>
        <Grid>
            <StackPanel>
                <TextBox Text="{Binding Path=Id}" Margin="5" Background="Red" />
                <TextBox Text="{Binding Path=Name}" Margin="5" Background="Red" />
                <TextBox Text="{Binding Path=Age}" Margin="5" Background="Red" />
            </StackPanel>
        </Grid>
    </StackPanel>
</Window>

技术分享

 

WPF Demo17 数据绑定

原文:http://www.cnblogs.com/YYkun/p/6872990.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!