现在的位置: 首页 > 综合 > 正文

Asynchronous Web and Network Calls on the Client in WPF(摘录)

2012年08月17日 ⁄ 综合 ⁄ 共 1160字 ⁄ 字号 评论关闭

1. Solution:WebApp, WpfAff

2. WebApp add :  Silverlight-enabled WCF Service

[OperationContract]
        public IList<Customer> GetCustomers()
        {
            List<Customer> results = new List<Customer>();
            results.Add(new Customer {LastName="Brown",FisrtName="Pete" });
            results.Add(new Customer { LastName = "Stagner", FisrtName = "Joe" });
            results.Add(new Customer { LastName = "Liberty", FisrtName = "Jesse" });
            results.Add(new Customer { LastName = "Galloway", FisrtName = "Jon`" });
            return results;
        }

3. WpfApp:

       private void CallService_Click(object sender, RoutedEventArgs e)
        {
            var client = new Service.CustomerServiceClient();
            client.GetCustomersCompleted += (s, ev) =>
            {
                CustomerList.ItemsSource = ev.Result;
            };
            client.GetCustomersAsync();
        }

---------------------------------------------------

                   <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding LastName}" />
                        <TextBlock Text=", " />
                        <TextBlock  Text="{Binding FisrtName}"/>
                    </StackPanel>
                </DataTemplate>

Solution:

WpfAsynCall

 

抱歉!评论已关闭.