Actually it is an ObservableCollection of ListValue objects. ListValue
probably confused you, but it is in fact our own class, not some sort of
List of items.

 

Just a theory I have; perhaps I am calling PropertyChanged from the wrong
thread? I would have thought that the PropertyChanged event would still have
been available in the worker thread (it is an asynchronous call) and would
have raised an exception in that case. Not sure...

 

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Miguel Madero
Sent: Thursday, 4 March 2010 7:41 PM
To: ozSilverlight
Subject: Re: Silverlight ComboBox ItemsSource won't OneWay bind

 

Short version, try using an ObservableCollection or creating a new
enumerable instead of adding items to the same list. 


 

Hope this helps, I'm not sure if this is the issue since you mentioned that
the event is null, which I didn't expect, so it might be something else.

 

 

Long version

Keep in mind that the databinding framework won't refresh the target if the
item is the same, which is what happens in your case. This is my
understanting of the DBFx. 

 

The DataBinding Fx gets the binding from the controls on load. 

The DBFx checks if the source (or any class on the PropertyPath), in this
case your ListProvider implements INotifyPropertyChange and if it does it
subscribes to it. 

The DBFx asks the source for a value and stores it (not exactly, but let's
keep it simple)

Thd DBFx sets the value of the appropriate property in the target (the
control)

The control updates its value

 

Next time, something happen and the source (ListProvider) raises a property
change notification. 

The DBFx gets the value of the property that changed and compares it witht
he current value. If it's the same it doesn't set it (to avoid unnecessary
changes in the UI). 

    I think this is the main problem in your case, since you are returning
the same instance. 

If the values are different, then it procceeds to set the value of the
appropriate property in the target (the control)
The control update its value

 

 

If you use an observable collection all the ItemsControl, the DataGrid et al
will subscribe to the CollectionChanged event if the value for the
ItemsSource implements ICollectionChanged. This isn't part of the
DataBinding Framework and it's handled on each individual control (or a base
class in some cases). 

 

 

 

Other things to try

Set a breakpoint in the getter to see if it's called and look at the stack
to see if the Databinding Fx is calling it

Check the output window for BindingExpressionExceptions, you might have a
type. 

Set the ThrowOnException property of the binding object to true to see if
there's a problem getting the value (not sure about the name, but you'll
find it). The DBFx will swallow all exceptions by default and in some
instances it won't refresh faulted bindings (e.g. getting a value of a
Property in the path failed, so it never subscribed to the IPropertyChanged
of that object). 

 

 


-- 
Miguel A. Madero Reyes
www.miguelmadero.com (blog)
[email protected]

_______________________________________________
ozsilverlight mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight

Reply via email to