C# 标签内容不会随绑定而更改
我目前在更新标签内容时遇到问题。我在这里是否缺少一些东西,以便在C# 标签内容不会随绑定而更改,c#,wpf,binding,C#,Wpf,Binding,我目前在更新标签内容时遇到问题。我在这里是否缺少一些东西,以便在当前计划物业更新时更新?执行情况见下文: 在我的xaml代码中,我有一个名为LabelProductionPlan的标签,设置如下: <Label x:Name="LabelProductionPlan" Content="{Binding Current_Plan.ProductionPlanName, Mode=TwoWay,
当前计划
物业更新时更新?执行情况见下文:
在我的xaml代码中,我有一个名为LabelProductionPlan
的标签,设置如下:
<Label x:Name="LabelProductionPlan"
Content="{Binding Current_Plan.ProductionPlanName,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"/>
FrontEndManager
通过以下设置来实现属性更改:
[ImplementPropertyChanging]
public class FrontEndManager
{
public ProductionPlanModel Current_Plan { get; set; }
}
随着生产计划模型
的实施以及属性更改
:
[ImplementPropertyChanging]
public class ProductionPlanModel
{
public string ProductionPlanName { get; set; }
}
您正在使用、更改的事件不被大多数依赖项属性使用,例如您在
标签中绑定到的内容。您需要使用INotifyPropertyChanged
事件,该事件在值完全更改并且可以使用时提供通知。如前所述,您似乎需要使用Fody.PropertyChanged
。我认为您使用了错误的Fody工具-您需要Fody.propertychange我刚刚找到了INotifyPropertyChanging的实际使用案例,而不是丑陋的“抛出异常以停止属性设置程序”-@Peregrine您说得对!你愿意提交吗?这样我就可以接受你的回答了?非常感谢你抓住了这个机会!
[ImplementPropertyChanging]
public class ProductionPlanModel
{
public string ProductionPlanName { get; set; }
}