首页 新闻 赞助 找找看

WPF Label绑定到ViewModel中类的一个属性,不生效。

0
悬赏园豆:20 [已解决问题] 解决于 2015-05-27 19:11

View中 Label绑定:

<Label Content="{Binding Source=InitInformation,Path=TestTypeName,UpdateSourceTrigger=PropertyChanged}" Grid.ColumnSpan="3"/>

ViewModel中:

private MeasurementInitInformation _initInformation=new MeasurementInitInformation();

        public MeasurementInitInformation InitInformation
        {
            get { return _initInformation; }
            set
            {
                _initInformation = value;
                OnPropertyChanged("InitInformation");
            }
        }

 public class MeasurementInitInformation : BindableBase

    {
        private string _testTypeName ;

        public string TestTypeName
        {
            get
            {
                return _testTypeName;
            }
            set
            {
                _testTypeName = value;
                OnPropertyChanged("TestTypeName");
            }
        }
}

赋值:InitInformation.TestTypeName =“testName”;

 

页面无响应,大侠告诉我我哪里错了啊 

pkyou的主页 pkyou | 初学一级 | 园豆:98
提问于:2015-05-27 18:55
< >
分享
最佳答案
-1

将label绑定改为:

 <Label Grid.Column="3" Content="{Binding InitInformation.TestTypeName}"  Grid.ColumnSpan="9"
                           Style="{StaticResource LabelStyle}"/>

即可

pkyou | 初学一级 |园豆:98 | 2015-05-27 19:11
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册