IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Silverlight Discussion :

Probleme affichage données dans datagrid


Sujet :

Silverlight

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    207
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2009
    Messages : 207
    Points : 60
    Points
    60
    Par défaut Probleme affichage données dans datagrid
    Bonjour tout le monde ,je souhaite afficher des données dans une datagrid, probleme, je dois obligatoirement sélectionner une ligne de mon datagrid pour que cette derniere affiche la totalité des résultats.

    VOici mon code :
    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
     
    public int nbLogs;
            public List<LogsConnexion>LesLogs = new List<LogsConnexion>();
            public Logs()
            {
                InitializeComponent();
                Loaded += new RoutedEventHandler(Logs_Loaded); 
            }
     
            void Logs_Loaded(object sender, RoutedEventArgs e)
            {
                ServiceWCF.ServiceWCFClient client = new SilverlightApplication2.ServiceWCF.ServiceWCFClient();
                client.GetNbLogsCompleted += new EventHandler<SilverlightApplication2.ServiceWCF.GetNbLogsCompletedEventArgs>(client_GetNbLogsCompleted);
                client.GetNbLogsAsync(App.CodeIdent, App.MonPdaSelectionne.IMEI);
     
            }
            void client_GetNbLogsCompleted(object sender, SilverlightApplication2.ServiceWCF.GetNbLogsCompletedEventArgs e)
            {
                nbLogs = e.Result;
                ServiceWCF.ServiceWCFClient client = new SilverlightApplication2.ServiceWCF.ServiceWCFClient();
                client.GetIdConnexionCompleted += new EventHandler<SilverlightApplication2.ServiceWCF.GetIdConnexionCompletedEventArgs>(client_GetIdConnexionCompleted);
                client.GetIdConnexionAsync(App.CodeIdent, App.MonPdaSelectionne.IMEI);
            }
            void client_GetIdConnexionCompleted(object sender, SilverlightApplication2.ServiceWCF.GetIdConnexionCompletedEventArgs e)
            {
                decimal[] IdConnexion = e.Result.ToArray();
                ServiceWCF.ServiceWCFClient client = new SilverlightApplication2.ServiceWCF.ServiceWCFClient();
                client.GetInfosLogCompleted += new EventHandler<SilverlightApplication2.ServiceWCF.GetInfosLogCompletedEventArgs>(client_GetInfosLogCompleted);
                for (int i = 0; i < nbLogs; i++)
                {
                    LogsConnexion log = new LogsConnexion() { Id = IdConnexion[i] };
                    client.GetInfosLogAsync(IdConnexion[i], log);
                }
            }
            void client_GetInfosLogCompleted(object sender, SilverlightApplication2.ServiceWCF.GetInfosLogCompletedEventArgs e)
            {
                ServiceWCF.ServiceWCFClient client = new SilverlightApplication2.ServiceWCF.ServiceWCFClient();
                LogsConnexion log = e.UserState as LogsConnexion;
                string[] infos = e.Result.ToArray();
                log.Date = infos[0];
                log.ICCID = infos[1];
                log.OS = infos[2];
                log.Revision = infos[3];
                log.AKU = infos[4];
                log.Identifiant = infos[5];
                log.OSEburo = infos[6];
                log.Sim = infos[7];
                LesLogs.Add(log);
                MaDataGrid.ItemsSource = LesLogs;
            }
    Est ce que quelqu'un pourrait m'éclaircir?

    Merci d'avance

  2. #2
    Membre habitué
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    121
    Détails du profil
    Informations personnelles :
    Âge : 38
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2008
    Messages : 121
    Points : 135
    Points
    135
    Par défaut
    Je ne suis pas sur que sa marche mais je crois avoir rencontré un problème a peu près similaire essaye de faire :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    LesLogs.Add(log);
    MaDataGrid.ItemsSource = null;
    MaDataGrid.ItemsSource = LesLogs;
    ou encore au lieu de faire un set à chaque réception de log, tu fais le set une seule fois quand tu as fini d'avoir tout les logs
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    int iLogCompleted;
    if(iLogCompleted == nbLogs)
        MaDataGrid.ItemsSource = LesLogs;

  3. #3
    Expert éminent sénior
    Avatar de Skyounet
    Homme Profil pro
    Software Engineer
    Inscrit en
    Mars 2005
    Messages
    6 380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 6 380
    Points : 13 380
    Points
    13 380
    Par défaut
    Remplace ta List<> par un ObservableCollection<> et assigne une seule fois l'ItemsSource (dans le Loaded par exemple).

Discussions similaires

  1. probleme affichage données datagrid
    Par noname_971 dans le forum Windows Forms
    Réponses: 0
    Dernier message: 02/04/2009, 17h09
  2. Probleme affichage données dans un tableau
    Par spider_sup dans le forum NetBeans
    Réponses: 0
    Dernier message: 15/08/2008, 11h10
  3. Réponses: 3
    Dernier message: 01/06/2006, 19h45
  4. [C#] Probleme de pagination dans datagrid
    Par asphareth dans le forum ASP.NET
    Réponses: 2
    Dernier message: 21/07/2004, 11h25

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo