码迷,mamicode.com
首页 > Windows程序 > 详细

WPF Demo17 数据绑定

时间:2017-05-18 14:43:49      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:path   ext   present   alt   ati   string   技术分享   res   win   

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

技术分享

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 数据绑定

标签:path   ext   present   alt   ati   string   技术分享   res   win   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!