views:

306

answers:

1

I am trying to write a fairly simple user control in Silverlight 2 that allows the user to search for existing addresses, optionally update the selected address, and add new addresses.

To this end I have put together a simple WCF service that allows for simple querying and I am currently wiring this up to a textbox, listbox combination (soon to replaced with the AutoCompleteBox from the Silverlight Toolkit).

My issue is more one of understanding, the return type from my service is of type IList<Address> and Address does not implement INotifyPropertyChanged and it doesn't seem appropriate for objects returned from the service (which may also be called by other clients) to have SL2 specific functionality baked in. What is the best approach to use to facilitate two-way binding to edit existing addresses.

Basic idea follows thus:

  1. User enters information into textbox
  2. Service called to retrieve matching addresses IList<Address> which is being returned as ObservableCollection<Address> in the Reference.cs for my service
  3. Returned values are set as the listbox's ItemSource
  4. User selects correct address and indicates an update is required
  5. Address instance bound to control container containing multiple textboxes

Essentially I want any changes in the bound textboxes to be reflected automatically in the Address instance, but without INotifyPropertyChanged how will this work? Do I have to create another class in my SL2 application that effectively overrides the property implementations for my service data object?

Can anyone out there point me in the right direction on this one as it's just not making sense to me...

Cheers,

Steve

+3  A: 

How are you generating the WCF proxies? I used "Add Service Reference..." from an SL2 project in VS2008, and my generated proxies do implement INotifyPropertyChanged (even though the server-side types don't).

For regular WCF (not SL2), svcutil has a /enableDataBinding switch that does all this. If you are using the IDE, there may be a checkbox.

Because these proxies are generated from the metadata, they are completely independent of the server-side code, so there is no issue with the SL2 version implementing INotifyPropertyChanged.

Marc Gravell
I am using the "Add Service Reference" dialog in VS.NET 2008, viewing the service reference settings once the reference has been created doesn't appear to include a likely looking option.
Stephen Newman
Just as a follow on, /enableDataBinding seems to work a treat, just hoping I can find an option in the IDE...
Stephen Newman
Remember - letting the IDE handle all of the proxy generating for you isn't always the best idea, especially if you're trying to do anything that's not default behavior.
Terry Donaghe
I think the checkbox is on the "Advanced..." page
Marc Gravell