Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>maulkye,</p> <p>There is something going wrong if you have to refresh your <code>ObservableCollection</code>. Usually, you should not need it because the <code>ObservableCollection</code> will notify about item changes.</p> <p>Never do this:</p> <pre><code>FruitBasket = new ObservableCollection&lt;Fruit&gt;(FruitBasket); </code></pre> <p>Your <code>public ObservableCollection&lt;Fruit&gt; FruitBasket</code> should have <strong>no public setter</strong>, it should be read only. Just <code>Add</code> or <code>Remove</code> Items to/from the list.</p> <p>If you want to handle multiple selections, you will probably need an extended <code>CollectionView</code> which can handle this, get more hints <a href="http://grokys.blogspot.com/2010/07/mvvm-and-multiple-selection-part-iii.html" rel="nofollow">here</a>.</p> <p>I hope this helps a little bit, even if I probably didn't answer all questions : )</p> <p><strong>EDIT:</strong> Ok, I guess i got some things wrong. Now i guess i fully understand what you're trying to accomplish. You are <strong>not</strong> getting notified when your property is changed, right? Well, for this reason, we've adapted "<a href="http://bindablelinq.codeplex.com" rel="nofollow">BindableLinq</a>" in one of our projects, which you can compile in Silverlight without problems. (there are similar solutions available, called <a href="http://clinq.codeplex.com/" rel="nofollow">Continuous Linq</a> or <a href="http://obtics.codeplex.com/" rel="nofollow">Obtics</a>, make your choice).</p> <p>Using <strong>BindableLinq</strong>, you can transform your <code>ObservableCollection</code> to a <code>BindableCollection</code> using one single extension method. The <code>BindableCollection</code> will then reflect all changes properly. Give it a try.</p> <p><strong>EDIT2:</strong> To implement a <strong>proper</strong> ViewModel, Please consider the following Changes.</p> <p>1) <code>Fruit</code> is your <strong>Model</strong>. Since it doesn't implement <code>INotifyPropertyChanged</code>, it won't propagate any changes. Create a <code>FruitViewModel</code>, embedding your <code>Fruit</code> Model and invoke <code>RaisePropertyChanged</code> for each property setter.</p> <p>2) Change your <code>FruitBasket</code> to be an <code>ObservableCollection</code> of <code>FruitViewModel</code>. Slowly it starts to make sense :)</p> <p>3) <code>SelectedFruit</code> has to be a <code>FruitViewModel</code> as well. Now it makes even more sense.</p> <p>4) Now it already works for me, even without <code>BindableLinq</code>. Did you have any success?</p> <p>HTH</p> <p>best regards,<br> thomas</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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