I'm trying since days to get a PropertyChanged event from my wcf-service to a wcf-client if a collection on server side has changed(by client action or server action). There must be a better solution instead of using callbacks and reload the list... or?
on server side: (almost like an example from another post) ObservableCollection and CollectionChanged event as WCF datacontract
public interface IObservableService
{
[OperationContract(IsOneWay = false)]
Data getData();
}
[DataContract]
public class Data : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void Notify(string propertyName)
{
if (this.PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
Console.WriteLine("Notify()");
}
}
private ObservableCollection<string> list;
internal Data()
{
list = new ObservableCollection<string>();
list.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(list_CollectionChanged);
}
void list_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
Console.WriteLine("list_CollectionChanged");
Notify("DataList");
Notify("Data");
}
[DataMember]
public ObservableCollection<string> DataList
{
get
{
return list;
}
set {
list = value;
Console.WriteLine("set DataList");
Notify("DataList");
Notify("Data");
}
}
}
on client side:
ObservableServiceClient client = new ObservableServiceClient();
Data data = client.getData();
So far its working... i can query the collection at client side, but i don't receive "propertyChanged" when something changes on the servers collection?
What's wrong? Where is my mistake & missunderstanding?