• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
繁星
不要浪费时间
博客园    首页    新随笔    联系   管理    订阅  订阅

数据绑定

1、TextBox与Slider数据双向绑定

  <TextBox HorizontalAlignment="Left" Margin="155,154,0,0" TextWrapping="Wrap" Text="{Binding Value,Mode=TwoWay,ElementName=slider1}" VerticalAlignment="Top" Height="38" Width="217"/>
        <Slider x:Name="slider1" HorizontalAlignment="Left" Margin="155,245,0,0" Minimum="0" Maximum="100" VerticalAlignment="Top" Width="344"/>

 

 public class person : INotifyPropertyChanged
    {
        private string _name;
        public string Name
        {
            get { return _name; }
            set
            {
                _name = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("Name"));
                }
            }
        }
        private string _age;
        public string Age
        {
            get { return _age; }
            set
            {
                _age = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("Name"));
                }
            }
        }
        //
        public event PropertyChangedEventHandler PropertyChanged;
    }

posted @ 2013-03-14 20:21  ※繁星※  阅读(133)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3