private void OKButton_Click(object sender, RoutedEventArgs e) { //((NotesTemplateItemsViewModel)LayoutRoot.DataContext).SaveItemsToNoteTempLate(); int userid = (App.Current as App).CurrentUserId; foreach (var item in ((NotesTemplateItemsViewModel)LayoutRoot.DataContext).AvailableNoteTemplateItem) { if (item.PromotionProduct) // here reuse this column to hold the selection of check box { if (selecteditemids == "") { selecteditemids = item.ProductAreaGroupID.ToString(); } else { selecteditemids = selecteditemids + "," + item.ProductAreaGroupID.ToString(); } //_selectednotetemplateitem.Add(item); } } mrsClient2 = new RetailSystemClient(); mrsClient2.Endpoint.Address = new System.ServiceModel.EndpointAddress(Internal.Utilities.GetMetriconRetailSystemWcfClientEndpointUrl()); mrsClient2.AddItemToNotesTemplateCompleted += new EventHandler <AddItemToNotesTemplateCompletedEventArgs>(mrsClient2_AddItemToNotesTemplateCompleted); mrsClient2.AddItemToNotesTemplateAsync(AddNotesTempateItems._templateid, selecteditemids, userid); mrsClient2 = null; }