Click here to Skip to main content
15,889,403 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i am trying to bind the data into data grid from WCF callback services.but i am unable to read data into client side.but i am getting data into WCF call back service implement method.

i have created wcf services like below

[ServiceContract(CallbackContract = typeof(ICalcServiceCallback))]
    public interface ICalcService
    {
        [OperationContract(IsOneWay = true)]
        void Calculatedatafrompath(string path, double[] returnPeriods);

}

i have created call back interface like below
public interface ICalcServiceCallback
   {

       [OperationContract(IsOneWay = true)]
       void SendResult(CalcUpdate CalcUpdate);
   }

i have implemented ICalcService method like below
public class CalcService:ICalcService
    {
        
        public void Calculatedatafrompath(string path, double[] returnPeriods)
        {
           //i written my code here

       }<pre>

in wpf application i have  created one Wpf window in that window.xaml.cs i have written code below 
<pre> public partial class Data : Page
    {
        
        private static PMLCalcService.PMLCalcServiceClient Calc;
        private static PMLCalcService.IPMLCalcServiceCallback Pml_callback;
        DuplexServiceCallBackHandler dd = new DuplexServiceCallBackHandler();
        public Data()
        {
            InitializeComponent();
        }

        private void PropertiesTabCtrl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (PropertiesTabCtrl.SelectedItem == tabname)
                {
                    InstanceContext context = new InstanceContext(new DuplexServiceCallBackHandler());
                    Calc = new CalcService.CalcServiceClient(context, "WSDualHttpBinding_ICalcService");
                    Calc.Calculatedatafrompath(path, returnPeriods);
                    
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
    }
   
    public class DuplexServiceCallBackHandler:PMLCalcService.IPMLCalcServiceCallback
    {
        
        void ICalcServiceCallback.SendResult(CalcUpdate CalcUpdate)
        {

            datainfo = CalcUpdate.data;
            if (datainfo != null)
                GridData(datainfo );
                
        }
        public DataTable GridData(double[] datainfo )
        {
         double[] d= datainfo; 
           
            //if (pp != null)
            //{
            dt.Columns.Add("ReturnPeriod", typeof(double));
            dt.Columns.Add("PML", typeof(double));
            for (int d = 0; d < returnPeriods.Count(); d++)
            {
                DataRow dr = dt_PML.NewRow();
                dr[0] = returnPeriods[d];
                dr[1] = pmls[d];
                dt.Rows.Add(dr);
                //}

            }
            
            return dt;//i am getting data here
        }
    }

i have implemented DuplexServiceCallBackHandler class in same xaml.cs,here i am getting data in GridData method, but i am unable to read data in PropertiesTabCtrl_SelectionChanged event.

any one could you please share your solutions to me.

What I have tried:

from past two days i am trying to bind data into wpf data grid,i am getting data into Wcfcallbackservice but i am unable to read data in client side.
past two days i am google it and i tried so many solutions.but it's not worked.
Posted
Updated 4-Jan-18 20:29pm
v8

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900