Bonjour,

Je souhaiterais Binder une collection contenu dans une autre collection à un DataGrid et je n’y arrive pas en XAML.

Voici le contexte :

J’ai une collection "LocalAlertsCollection" de type "LocalAlert" qui contient une autre collection "AlertInfoCollection" de type "AlertInfo"

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
 
// Class definition - C#
 
public class LocalAlertsCollection : ObservableCollection<LocalAlert> { }
 
public class LocalAlert
{
        public bool _isNew { get; set; }
        public AlertInfoCollection _informations { get; set; }
}
 
public class AlertInfoCollection : ObservableCollection<AlertInfo> { }
 
public class AlertInfo
{
       public string _title { get; set; } 
}

J’ai binder la collection "LocalAlertsCollection" à mon DataGrid appelé "LocalAlertsDG". (Cela fonctionne )

Et je voudrais binder ma “sous-collection” "AlertInfoCollection" à un autre DataGrid appelé "LocalAlertsDetailsDG" qui se situe dans le RowDetailsTemplate du DataGrid "LocalAlertsDG". (Cela ne fonctionne pas )

Je ne sais pas comment accéder au membre de la collection " AlertInfoCollection " de type « AlertInfo » afin de pouvoir le binder à mon DataGrid "LocalAlertsDetailDG".

J’avais pensé à cela mais sans succès :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
<data:DataGrid x:Name="LocalAlertsDG"> //Binded to a LocalAlertCollection programatically
       <data:DataGrid.RowDetailsTemplate>
           <DataTemplate>
                 <data:DataGrid x:Name="LocalAlertsDetailsDG" ItemSource={Binding Mode=OneWay, Path=_informations}"> 
                          <data:DataGrid.Columns>
                                         <data:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=_title}"/>
                          </data:DataGrid.Columns>
                 </data:DataGrid> 
 
           </DataTemplate>
       </data:DataGrid.RowDetailsTemplate>
<data:DataGrid>
Merci pour votre aide,
Steven