Hi all,

I have a strange situation where the ItemsSource property on a combo box won't 
OneWay bind to 
the data source. That is, after the initial bind to the ItemsSource bound 
property, I change the 
contents of that bound collection, call the PropertyChanged event for that 
property, but it doesn't 
update the combo box list.

Here's the resource:

<navigation:Page.Resources>
 <lst:ListProvider x:Key="ListProvider" d:IsDataSource="True"  />
</navigation:Page.Resources>

Here's the Combo Box declaration:
<ComboBox Grid.Row="0" Grid.Column="1" 
 x:Name="cmbTermCategory" 
 ItemsSource="{Binding Path=TermCategoryList, Mode=OneWay, 
Source={StaticResource 
ListProvider}}"  
 Style="{StaticResource ComboBoxStyle}" Height="24" 
 DisplayMemberPath="Description" 
/>

Here's the ListProvider class: (hopefully only irrelevant code removed)
public sealed  class ListProvider : INotifyPropertyChanged  
{
  private ObservableCollection<ListValue> moTermCategoryList 
      = new ObservableCollection<ListValue>();
   public ObservableCollection<ListValue> TermCategoryList 
   { 
       get 
       {
           return moTermCategoryList; 
       }
       set
       {
           moTermCategoryList = value;
           OnPropertyChanged("TermCategoryList");
       }
   }

   #region INotifyPropertyChanged Members

   public event PropertyChangedEventHandler PropertyChanged;

   private void OnPropertyChanged(string propertyName)
   {
       if (PropertyChanged != null)
           PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
   }

   #endregion // INotifyPropertyChanged Members

}


When the screen loads, it initially calls the bind to the TermCategoryList 
property. At that time the 
list is empty. I make a database call to populate the list and when it is 
finished, I call 
OnPropertyChanged("TermCategoryList"). I would have thought that this would 
cause the bind to 
be refired and the get should re-execute, but it doesn't. 

In fact, the PropertyChanged event is not even set - it's null.

...snip from within my OnLoadCompleted async callback method:

  moTermCategoryList.Clear();
  foreach (ListValue item in poLoadOperation.Entities)
  {
     moTermCategoryList.Add(item);
  }
  OnPropertyChanged("TermCategoryList");

Any idea what I might be missing?

Regards,
Tony

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

Reply via email to