Bonjour,
Je débute avec wpf c# et je rencontre un problème au niveau des images.
Voici mon code xaml:
et voici mon code c#:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <DataGrid HorizontalAlignment="Left" Margin="10,10,0,0" Height="300" Width="870" ItemsSource="{Binding liste}" AutoGenerateColumns="False"> <DataGrid.Columns > <DataGridTextColumn Header="Image" Binding="{Binding MyImage}" Width="70" /> <DataGridTextColumn Header="Titre" Binding="{Binding Titre}" Width="250"/> </DataGrid.Columns> </DataGrid>
les images se trouvent bien dans le projet. J'arrive à afficher les textes mais pour l'image, je ne comprend pas. Si quelqu'un à une idée, je vous remercie d'avance.
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 public ObservableCollection<ListData> liste { get; set; }; public MainWindow() { liste = new ObservableCollection<ListData>(); InitializeComponent(); this.DataContext = this; liste.Add(new ListData("imagess/word.png", "CMMI2")); liste.Add(new ListData("imagess/word.png", "CMMI3")); } } } public class ListData { private ImageSource _image; private string _titre; public ListData(String image, string titre) { _image = image; _titre = titre; } public String MyImage { get { return _image; } set { _image = value; } } public string Titre { get { return _titre; } set { _titre = value; } } }
Cordialement
Partager