0

I'm currently having problems with my label content being updated. Is there something I'm missing here to have it update on Current_Plan property update? See below for implementation:

In my xaml code I have a Label called LabelProductionPlan set up like the following:

   <Label x:Name="LabelProductionPlan" 
          Content="{Binding Current_Plan.ProductionPlanName, 
                            Mode=TwoWay,
                            UpdateSourceTrigger=PropertyChanged}"/>

In my MainWindow.xaml.cs file, the setup is as follows:

public partial class MainWindow : Window
    {

        private FrontEndManager FEM;

        public MainWindow()
        {
            InitializeComponent();
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;


            FEM = new FrontEndManager
            {
                Current_Plan = new ProductionPlanModel
                {

                }

            };

            LabelProductionPlan.DataContext = FEM;
        }}

The FrontEndManager is setup with the following Fody feature to implement PropertyChanging:

[ImplementPropertyChanging]
public class FrontEndManager
{
    public ProductionPlanModel Current_Plan { get; set; }
}

With the ProductionPlanModel implemented as well with PropertyChanging:

[ImplementPropertyChanging]
public class ProductionPlanModel
{
    public string ProductionPlanName { get; set; }
}
ΩmegaMan
  • 29,542
  • 12
  • 100
  • 122
KyleKW
  • 300
  • 1
  • 11
  • 1
    I think you're using the wrong Fody tool - you want Fody.PropertyChanged – Peregrine Oct 31 '18 at 16:39
  • I've just found an actual use case for INotifyPropertyChanging other than the ugly "throw an exception to stop a property setter" - https://stackoverflow.com/a/41472332/967885 – Peregrine Oct 31 '18 at 16:48
  • @Peregrine You are right! Would you like to submit that so I can accept your answer? Thank you so much for catching that! – KyleKW Oct 31 '18 at 17:03

1 Answers1

-1

The event you are using, changing is not used by most dependency properties, such as the Content you have bound to in a Label. You need to use INotifyPropertyChanged event which supplies a notification when the value fully changes and can be used. As mentioned it appears you need to use Fody.PropertyChanged instead.

ΩmegaMan
  • 29,542
  • 12
  • 100
  • 122