0
Reply

CollectionViewSource cast as List

Andrew Fannin

Andrew Fannin

Jun 27 2011 2:14 PM
3.2k
I am new to Silverlight programming and am currently working on a data driven web application using a WCF service.  I have found a generic filter for filtering the datagrid which I really like.  However, when I run my linq query to get the data from a table, I am putting it into a CollectionViewSource.  For the filtering to work properly, I need to cast this as a list.  Any ideas how this would be possible?  Or is there a better way to consume the data than using a CollectionViewSource.

I am trying to return the query results into a List.  However at runtime, I always get "null" for the list.
Here is my linq query and how I call the service.

  public List<uvw_WXT520> GetWeather()
  {
  return (from t in DataContext.uvw_WXT520
  orderby t.SampleDate_UTC descending
  select t).Take(1000).ToList();
  }

  List<uvw_WXT520> list = (List<uvw_WXT520>)this.Resources["uvw_WXT520List"];
  _Proxy.GetWeatherCompleted += (s, args) => list = args.Result;
  _Proxy.GetWeatherAsync();