Bonjour, tout le monde, j'ai un probleme en silverlight en effet je fais appel à plusieurs méthodes me permettant d'ajouter des informations dans un objet FondEcran pour ensuite afficher le tout dans une listbox
ces méthodes me permettent de faire des requetes au sein de la base de données, les images sont enregistrés en tableau de byte.

Voici un extrait de mon code c# :

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
34
35
void client_GetFondsEcranPDACompleted(object sender, SilverlightApplication2.ServiceWCF.GetFondsEcranPDACompletedEventArgs e)
        {
 
            ServiceWCF.ServiceWCFClient client = new SilverlightApplication2.ServiceWCF.ServiceWCFClient();
            client.GetFondsEcranPDACompleted -= new EventHandler<SilverlightApplication2.ServiceWCF.GetFondsEcranPDACompletedEventArgs>(client_GetFondsEcranPDACompleted);           
            String[] FondsEcran;
            FondsEcran = e.Result.ToArray();        
            client.GetIdImageFondEcranCompleted += new EventHandler<SilverlightApplication2.ServiceWCF.GetIdImageFondEcranCompletedEventArgs>(client_GetIdImageFondEcranCompleted);    
            for (int i = 0; i < FondsEcran.Length; i++)
            {
                String NomFondsEcran = FondsEcran[i];
                FondEcran FdE = new FondEcran() { Nom = NomFondsEcran };
                client.GetIdImageFondEcranAsync(NomFondsEcran, FdE);            
            }
 
        }
 
        void client_GetIdImageFondEcranCompleted(object sender, SilverlightApplication2.ServiceWCF.GetIdImageFondEcranCompletedEventArgs e)
        {
            ServiceWCF.ServiceWCFClient client = new SilverlightApplication2.ServiceWCF.ServiceWCFClient();
            client.GetIdImageFondEcranCompleted -= new EventHandler<SilverlightApplication2.ServiceWCF.GetIdImageFondEcranCompletedEventArgs>(client_GetIdImageFondEcranCompleted);           
            FondEcran FdE = e.UserState as FondEcran;
            Decimal Id = e.Result;
            FdE.Id = Id;
            client.GetImageCompleted += new EventHandler<SilverlightApplication2.ServiceWCF.GetImageCompletedEventArgs>(client_GetImageCompleted);
            client.GetImageAsync(Id, FdE);
        }
        void client_GetImageCompleted(object sender, SilverlightApplication2.ServiceWCF.GetImageCompletedEventArgs e)
        {
            ServiceWCF.ServiceWCFClient client = new SilverlightApplication2.ServiceWCF.ServiceWCFClient();
            client.GetImageCompleted -= new EventHandler<SilverlightApplication2.ServiceWCF.GetImageCompletedEventArgs>(client_GetImageCompleted);                  
            FondEcran FdE = e.UserState as FondEcran;
            FdE.Image = e.Result;
            ListBoxFondsEcran.Items.Add(FdE);
        }
et mon code xaml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
<ListBox Height="157" HorizontalAlignment="Center" x:Name="ListBoxFondsEcran" VerticalAlignment="Top" Width="508" ScrollViewer.VerticalScrollBarVisibility="Auto" BorderBrush="{x:Null}" ScrollViewer.HorizontalScrollBarVisibility="Auto" Style="{StaticResource IziBlackStyleListBox}" HorizontalContentAlignment="Center" ItemsSource="{Binding}" Foreground="White" Background="#FFE86868">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Width="109">
                                    <Border BorderThickness="3" CornerRadius="3" Background="White" BorderBrush="white">
                                            <Image Source="{Binding Image, Converter={StaticResource ByteArrayToImageConverter}}" Height ="100" HorizontalAlignment="center" VerticalAlignment="center"/>
                                    </Border>
                                    <TextBlock Text="{Binding Nom}" HorizontalAlignment="center" VerticalAlignment="center"/>
                                </StackPanel>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
j'ai ajouté au tout debut de mon code xaml en ressource :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
<navigation:Page.Resources>
        <local1:ByteArrayToImageConverter x:Key="ByteArrayToImageConverter" />
        </navigation:Page.Resources>
Je n'ai pas d'erreur de syntaxe.