locked
Databinding and setting property with new object RRS feed

  • Question

  • Hi,

    i am using databinding on a poco object and the UI does not get the new values when setting the whole object.

    Example: POCO 

    public class LicenseEncryption : INotifyPropertyChanged
    {
            public string Name
            {
                get { return name; }
                set { name = value; NotifyPropertyChanged("Name"); }
            }
    //... Code for INotify not listened here
    }

    On the form i now bind a textbox to that property

    this.txtName.DataBindings.Add("Text", LicenseEncryption, "Name", true, DataSourceUpdateMode.OnPropertyChanged);

    This all works, but when i now set the whole object no databinding occurs

    this.LicenseEncryption = dataStore.GetLicenseEncryption(); // <- this seems to overwrite the whole object so the engine does not fire the ui update?


    .NET Developer


    Thursday, April 19, 2012 3:03 PM

Answers

  • Hi Rudsen,

    You just set the PropertyChanged for Name property. But >> this.LicenseEncryption = dataStore.GetLicenseEncryption();   just call the set method for LicenseEncryption, so it won't update your UI.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Alan_chen Tuesday, May 8, 2012 2:40 AM
    Tuesday, April 24, 2012 6:35 AM