Link to home
Start Free TrialLog in
Avatar of alainbryden
alainbrydenFlag for Canada

asked on

Binding not working (NotifyPropertyChanged firing but PropertyChanged is null)

Hey, I'm suffering a strange case where just one of my bindings won't work. I'm not sure why it's failing but I think it has to do with the data structure I'm binding too.

My binding statement is this:
            <Label  x:Name="Cedent"  ...
                        Content="{Binding Source={x:Static Application.Current},
                                          Path=ExposureMetaDataList.TTProgramInfo.Cedent}" />

My App.cs class has a property called ExposureMetaDataList
This, in turn has a property called TTProgramInfo, which is also a data structure.
This class has one private variable which is a data structure ttProgramInfo, and 3 public prperties which expose three properties of that data structure. The one being accessed is:

        public string Cedent {
            get {
                return ttProgramInfo.Cedent;
            }
            set {
                ttProgramInfo.Cedent = value;
                NotifyPropertyChanged("Cedent");
            }
        }

When the property "Cedent" is changed, the set method gets called, as does NotifyPropertyChanged:

        public event PropertyChangedEventHandler PropertyChanged;

        protected void NotifyPropertyChanged(String propertyName)
        {
            if(PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

But when that function gets called, 'PropertyChanged' is null, and so nothing happens. Why is it null? For every other bound property, the PropertyChanged eventhandler is magically set to something, but not in this case. How can I figure this out?

Below is the code where the property gets set. Note that the data structure is being reset too (but this should not harm the binding since it's set in the XAML and the data structure is initialized dynamically anyways.
ttProgramInfo = new TTProgramInfoVM();
if(ds != null && ds.Tables[0].Rows.Count > 0)
{
    //TODO: None of these properties are firing approprate notify property change events.
     ttProgramInfo.TTID = Convert.ToInt32(ds.Tables[0].Rows[0]["TTID"]);
     ttProgramInfo.Cedent = (String) ds.Tables[0].Rows[0]["Cedent"];
     ttProgramInfo.CCY = (String) ds.Tables[0].Rows[0]["CCY"];
     ((QuartzShareUI.App) Application.Current).TTIDLoggedIn = true;
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of alainbryden
alainbryden
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial