Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight DataBinding to a ReadOnlyObservableCollection only fires the first time
    text
    copied!<p>in my Silverlight 4 project, I like to bind an ReadOnlyObservableCollection to a Button Property. The collection is part of a class, which binds to the DataContect of the UserControl, that contains the Button.</p> <pre><code>&lt;Button Visibility="{Binding Children, Converter={StaticResource ConvertHasListItems2Visibility}}" /&gt; </code></pre> <p>The converter is called the first time, when the control is created, but after that, it isn't called when I add or remove items to the collection. I checked this with breakpoints. I even tried to bind to an ObservableCollection, but there is the same problem. Binding to another property of my class works (my class implements INotifyPropertyChanged).</p> <p>Is there anything special with binding to a (ReadOnly)ObservableCollection, that should notify, when its elements changed ( added or removed, to be exact)?</p> <p>Thanks in advance,<br> Frank</p> <p>Edith includes the declaration of the Collection(s):</p> <pre><code>public class MyClass { private ObservableCollection&lt;IServiceItemVMBase&gt; _children; private ReadOnlyObservableCollection&lt;IServiceItemVMBase&gt; _childrenReadOnly; public ViewModelBase(IServiceObjectBase serviceObject, IServiceItemVMBase parent) { _children = new ObservableCollection&lt;IServiceItemVMBase&gt;(); _childrenReadOnly = new ReadOnlyObservableCollection&lt;IServiceItemVMBase&gt;(_children); } public ReadOnlyObservableCollection&lt;IServiceItemVMBase&gt; Children { get { return _childrenReadOnly; } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload