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”;
页面无响应,大侠告诉我我哪里错了啊
将label绑定改为:
<Label Grid.Column="3" Content="{Binding InitInformation.TestTypeName}" Grid.ColumnSpan="9" Style="{StaticResource LabelStyle}"/>
即可