天天看点

WPF TextBox绑定数据的简单应用

 public class RWhiteBoard

    {       

        public string MCode

        {

            get { return publicPro.strMCode; }

            set { publicPro.strMCode = value; }

        }

        public string RCode

        {

            get { return publicPro.strRCode; }

            set { publicPro.strRCode = value; }

        }

    }

public class AA

{

           ...

            RWhiteBoard rw = new RWhiteBoard();

            Binding bi = new Binding();

            bi.Source = rw;

            bi.Path = new PropertyPath("MCode");            

            this.textBox1.SetBinding(TextBox.TextProperty, bi);

            ...

}