Category: WPF

WPF – Lire un fichier XML dans un gridview

Code XAML :
< Grid >
< ListView Name=”List1″ Margin=”35,34,28,123″ ItemTemplate=”{DynamicResource CustomerTemplate}” ItemsSource=”{Binding Path=Table}”>
< ListView.View>
< GridView>
< GridViewColumn Header=”Marque” DisplayMemberBinding=”{Binding Path=marque}”/>
< GridViewColumn Header=”Modele” DisplayMemberBinding=”{Binding Path=modele}”/>
< GridViewColumn Header=”Vitesse” DisplayMemberBinding=”{Binding Path=vitesse}”/>
< /GridView>
< /ListView.View>
< /ListView>
< /Grid>
Code Behind :
// lecture du fichier xml dans un gridview
string file = @”c:testxmlData1.xml”;
DataSet ds = new DataSet(“Table”);
ds.ReadXml(file);
List1.DataContext = ds.Tables[0].DefaultView;