Populate WrapDataGrid using WCF callback

Sep 3, 2009 at 12:39 AM

Hi,

I want to populate the WrapDataGrid using WCF service call. I tried as below. But it does not bind any values. If I use the Silverlight 3 DataGrid then it binds correctly. Or If I Bind the WrapDataGrid with  out WCF call it works fine. The problem is only when I Use WCF service call and bind it in the callback method.  The WCF service returns the correct values. It is just not binidng properly to the grid. I am using Silverlight 3. How can I make it work to bind in callback? Any help is appreciated.

 

        public MainPage()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(Page_Loaded);
        }

        public void Page_Loaded(object sender, RoutedEventArgs e)
        {

            ListService.ListServiceClient proxy = new ListServiceClient();
            ListService.ListRequest request = new ListRequest();

            request.Id = 1

            //Wire the proxy to a completed handler to allow the async operation to be handled
            proxy.GetCompleted +=
              new EventHandler<ListService.GetCompletedEventArgs>(
            proxy_GetCustomerCompleted);
            //Call the service asynchronously
            proxy.GetAsync(request);
        }

        private void proxy_GetCustomerCompleted1(object sender, GetCompletedEventArgs e)
        {
            this.WrapDataGrid.DataContext = e.Result;
        }

Nov 12, 2009 at 2:18 AM

I am also facing the same issue, pls help...

thanks in advance

 

Developer
Nov 17, 2009 at 9:02 AM

Hi there,

Can you confirm that you are calling Reload() after setting the DataContext?

Thanks,

Martin

Nov 17, 2009 at 2:38 PM

Hi Martin,

Yes I am calling reoload method too

Thanks

 

 

Developer
Nov 17, 2009 at 2:49 PM

Hi Spandy,

Could you try explicitly setting the data context on the UI thread. e.g...

        private void proxy_GetCustomerCompleted1(object sender, GetCompletedEventArgs e)
        {
            this.Dispatcher.BeginInvoke( SetDataContext, e.Result);
        }

        private void SetDataContext(object dataContext)
        {
            this.WrapDataGrid.DataContext = dataContext;
        }

Thanks,

Martin

Nov 29, 2010 at 8:06 PM

I am having the same issuse with WrapDataGrid.  I cannot Bind Data from a collection. The Data is there in the DataContext as objects but will not bind to datagrid.  Can anyone help?