读书人

深入显出WPF 第一部分(2)

发布时间: 2012-12-17 09:31:40 作者: rapoo

深入浅出WPF 第一部分(2)

3.2 XAML中为对象属性赋值的语法

3.2.1 使用标签的Attribute为对象属性赋值

using System.Windows;namespace FirstWpfApplication{    /// <summary>    /// Interaction logic for MainWindow.xaml    /// </summary>    public partial class MainWindow : Window    {        public MainWindow()        {            InitializeComponent();        }        public string Str { get; set; }        private void button1_Click(object sender, RoutedEventArgs e)        {            Human h = this.FindResource("human") as Human;            MessageBox.Show(string.Format("Name:{0} ChildName:{1}", h.Name, h.Child.Name));        }    }}



读书人网 >其他相关

热点推荐