Bonsoir

J'ai une liste de données que j'affiche avec un listview avec le xaml
Si je modifie la liste, la listview n'affiche pas les changements

Voici le 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Public Class Classdata
    Public Property thename() As String
        Get
            Return name
        End Get
        Set(ByVal value As String)
            value = name
        End Set
    End Property
 
    Public name As String
 
End Class
 
 The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
 
Imports System.Text
''' <summary>
''' An empty page that can be used on its own or navigated to within a Frame.
''' </summary>
Public NotInheritable Class MainPage
    Inherits Page
#Region "initialize"
  Private list1 As New List(Of Classdata)
  Private Sub initlist()
    Dim data As Classdata
        list1.Clear()
        For iter = 1 To 10
            data = New Classdata
            data.name = "AAAA" & iter.ToString
 
            list1.Add(data)
        Next
    End Sub
    Private Sub showlist()
        Dim myBind As Binding = New Binding()
 
        myBind.Source = list1
        myBind.Mode = BindingMode.twoWay
        Dgvresult.SetBinding(ListView.ItemsSourceProperty, myBind)
    End Sub
 
 Private Sub MainPage_Loading(sender As FrameworkElement, args As Object) Handles Me.Loading
 
     initlist()
     showlist()
    End Sub
 
Private Sub Buttonthisyear_Click(sender As Object, e As RoutedEventArgs) Handles Buttonthisyear.Click
        list1(1).name = "THENAMECHANGE"
        showlist()
    End Sub
 
#End Region
 
End Class
 
Le mainpage.xaml
<ListView x:Name="Dgvresult" 
        Width="800" Height="600" 
        ScrollViewer.VerticalScrollBarVisibility="Visible" BorderThickness="3,1,3,3" 
         HorizontalAlignment="Left" VerticalAlignment="Top" Margin="60,20,0,0">
         <ListView.ItemTemplate>
             <DataTemplate>
              <StackPanel x:Name="stackp" 
 
               Orientation="Vertical" Width="650" HorizontalAlignment="Left" Margin="69,0,0,0" 
               CornerRadius="6,6,6,6" BorderThickness="2,2,2,2" Height="Auto" 
                        >
               <TextBlock x:Name="namep" Text="{Binding thename}" 
                 FontSize="20" 
                 FontFamily="Calibri"
                 FontStyle="Normal" 
                 FontWeight="Bold"
                 Foreground="DarkSlateBlue" HorizontalAlignment="Left" Margin="492,0,0,0" 
                 VerticalAlignment="Center" TextAlignment="Center" 
                 HorizontalTextAlignment="Left" Padding="0,0,0,0" TextWrapping="Wrap"    />
 
               </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
Merci pour l'aide