I do have other combo boxes that do successfully bind on the page, which are 
pointing to static 
viewmodel resources. That is, the collection associated with the viewmodel is 
intially empty, then 
after the async callback, it is populated, calls the propertychanged event, 
then the combobox list is 
populated.

<vm:VendorViewModel x:Key="VendorViewModel" d:IsDataSource="True"  />

<ComboBox Grid.Row="1" Grid.Column="1" 
  x:Name="cmbVendor" 
  ItemsSource="{Binding Vendors, Source={StaticResource VendorViewModel}}" 
  Style="{StaticResource ComboBoxStyle}" Height="24" 
  DisplayMemberPath="VendorName" 
/>

Doesn't look much different to the ListProvider, except that the 
VendorViewModel inherits from the 
ViewModelBase, which implements INotifyPropertyChanged, whereas with the 
ListProvider, I 
implement INotifyPropertyChanged handler myself. I have changed it to inherit 
from 
ViewModelBase and then called the PropertyChanged event, but it is still null.



Note that I have checked that the collection is populated.


On Thu, Mar 4th, 2010 at 5:11 PM, Stephen Price <[email protected]> 
wrote:

> Possibly related to the fact you are using a property on a class
> that's
> referenced as a StaticResource? My understanding of StaticResource is
> that
> once it's created then it's immutable. That might not limit
> properties of
> said instance tho, so am just guessing. It might work fine if you
> were using
> a viewmodel and binding to the properties on that directly, rather
> than to a
> resource.
> 
> maybe not much help... :(
> 
> On Thu, Mar 4, 2010 at 1:50 PM, <[email protected]> wrote:
> 
> > 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
> >
> 



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

Reply via email to