Bonjour,
Je bute sur un problème très simple je cherche à remplir une datagrid sous silverlight depuis un service WCF qui renvoi une list<T> mais ma datagrid reste désespérément vide, pourtant avec l'outil de test WCF client le service renvoi sans problème le données de la liste.
Voici le code exemple que j'ai trouvé sur le web:
et le service en question
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 InitializeComponent(); Service1Client wcf = new Service1Client(); wcf.ReturnRockBanksCompleted += new EventHandler<ReturnRockBanksCompletedEventArgs>(wcf_ReturnRockBanksCompleted); wcf.ReturnRockBanksAsync(); void wcf_ReturnRockBanksCompleted(object sender,ReturnRockBanksCompletedEventArgs e) { dataGrid1.ItemsSource = e.Result; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 public class RockBand { public string RockkBandId { get; set; } public string RockkBandName { get; set; } } public class Service1 : IService1 { public void DoWork() { } public List<RockBand> ReturnRockBanks() { List<RockBand> rockbands = new List<RockBand>(); rockbands.Add(new RockBand() { RockkBandId = "1", RockkBandName = "Depeche Mode" }); rockbands.Add(new RockBand() { RockkBandId = "2", RockkBandName = "The Smiths" }); rockbands.Add(new RockBand() { RockkBandId = "4", RockkBandName = "Britney Spears" }); return rockbands; } }
Merci d'avance pour vos réponses !
Partager