How to trigger the Property Change from WCF service in Silverlight
-
Good Day All My Question goes as follows. I have a DataLayer in a Form of a WCF service and it is being consumed by a Business Layer that is also in a Form of a WCF Service and it is being consumed by a Silverlight Application. Now i have a Model in the DataLayer that defines the structure that comes from the Database, and this strucure model implements INotifyPropertyChanged interface to track the changes on the Properties. So basically , when the changes are made in silverlight , i want the Interface method to be fired in the Datalayer. now to go further with my requirement , i am doing the validation on the Properties like this
public string CustomerSurname { get { return \_CustomerSurname; } set { if (!string.IsNullOrEmpty(value)) { \_CustomerSurname = value; OnNotifyPropertyChanged("CustomerSurname"); } else { throw new Exception("Invalid Surname"); } } }
and obviously set binded control with the Proper binding property to show the Exception.
Text="{Binding CustomerSurname, Mode=TwoWay,ValidatesOnExceptions=True}"
The problem is the "changed" event does not get triggered, or rather my Exception does not show. Thanks
Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa[at]dotnetfunda.com http://www.Dotnetfunda.com
-
Good Day All My Question goes as follows. I have a DataLayer in a Form of a WCF service and it is being consumed by a Business Layer that is also in a Form of a WCF Service and it is being consumed by a Silverlight Application. Now i have a Model in the DataLayer that defines the structure that comes from the Database, and this strucure model implements INotifyPropertyChanged interface to track the changes on the Properties. So basically , when the changes are made in silverlight , i want the Interface method to be fired in the Datalayer. now to go further with my requirement , i am doing the validation on the Properties like this
public string CustomerSurname { get { return \_CustomerSurname; } set { if (!string.IsNullOrEmpty(value)) { \_CustomerSurname = value; OnNotifyPropertyChanged("CustomerSurname"); } else { throw new Exception("Invalid Surname"); } } }
and obviously set binded control with the Proper binding property to show the Exception.
Text="{Binding CustomerSurname, Mode=TwoWay,ValidatesOnExceptions=True}"
The problem is the "changed" event does not get triggered, or rather my Exception does not show. Thanks
Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa[at]dotnetfunda.com http://www.Dotnetfunda.com
Need NotifyOnValidationError?
Text="{Binding CustomerSurname, Mode=TwoWay,ValidatesOnExceptions=True,NotifyOnValidationError=True}"
Mark Salsbery :java:
-
Need NotifyOnValidationError?
Text="{Binding CustomerSurname, Mode=TwoWay,ValidatesOnExceptions=True,NotifyOnValidationError=True}"
Mark Salsbery :java:
-
Maybe the update source trigger...
Text="{Binding CustomerSurname,Mode=TwoWay,UpdateSourceTrigger="PropertyChanged",ValidatesOnExceptions=True,NotifyOnValidationError=True}"
Mark Salsbery :java:
-
Good Day All My Question goes as follows. I have a DataLayer in a Form of a WCF service and it is being consumed by a Business Layer that is also in a Form of a WCF Service and it is being consumed by a Silverlight Application. Now i have a Model in the DataLayer that defines the structure that comes from the Database, and this strucure model implements INotifyPropertyChanged interface to track the changes on the Properties. So basically , when the changes are made in silverlight , i want the Interface method to be fired in the Datalayer. now to go further with my requirement , i am doing the validation on the Properties like this
public string CustomerSurname { get { return \_CustomerSurname; } set { if (!string.IsNullOrEmpty(value)) { \_CustomerSurname = value; OnNotifyPropertyChanged("CustomerSurname"); } else { throw new Exception("Invalid Surname"); } } }
and obviously set binded control with the Proper binding property to show the Exception.
Text="{Binding CustomerSurname, Mode=TwoWay,ValidatesOnExceptions=True}"
The problem is the "changed" event does not get triggered, or rather my Exception does not show. Thanks
Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa[at]dotnetfunda.com http://www.Dotnetfunda.com
Hi, Don't know if you have solved this yet, but maybe this will help. I am assuming (oops) that your class is inheriting from INotifyPropertyChanged. Also I don't see in your code (you probably just aren't showing it) the event declaration ie public event PropertyChangedEventHandler PropertyChanged; as well as the OnNotifyPropertyChanged method, although if it wasn't there the OnNotifyPropertyChanged("CustomerSurname"); would complain loudly. The other thing I don't see , and this is what got me in the beginning, is setting the data context. Without it the binding doesn't work. so lets say you have this public class TestingBinding : INotifyPropertyChanged { All your code here } Then using your class: TestingBinding newBindTest = new TestingBinding(); this.DataContext = newBindTest; //<------ without this binding won't work. Hope that helps you out. Regards, Neill