S
Shay_w
Guest
Hi
It's an uwp blank application i use a listwiew to display a list of data
The list is display but one time ,if i update the list ,changes are not displayed
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 Property thedate() As String
Get
Return hdate
End Get
Set(ByVal value As String)
value = hdate
End Set
End Property
Public Property civildate() As String
Get
Return civild
End Get
Set(ByVal value As String)
value = civild
End Set
End Property
Public name As String
Public hdate As String
Public civild As String
End Class
The Blank Page item template is documented at C#, VB, and C++ project templates for Store apps
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
data.hdate = Date.Now.ToLongDateString
data.civild = Date.Today.ToShortDateString
list1.Add(data)
Next
End Sub
Private Sub showlist()
Dim myBind As Binding = New Binding()
myBind.Source = list1
myBind.Mode = BindingMode.OneWay
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
The 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" />
<TextBlock x:Name="thedate" Text="{Binding thedate}"
Margin="270,-26,0,0"
FontSize="20"
FontStyle="Normal"
Foreground="DarkSlateBlue"
FontWeight="Bold" FontFamily="Calibri"
HorizontalAlignment="Left" VerticalAlignment="Center"
Padding="0,2,0,0" TextWrapping="Wrap" />
<TextBlock x:Name="civildate" Text="{Binding civildate}"
Margin="90,-26,0,0"
FontSize="20"
FontStyle="Normal"
FontWeight="Bold"
Foreground="DarkSlateBlue" FontFamily="Calibri" HorizontalAlignment="Left" VerticalAlignment="Center"
Padding="0,0,0,0" TextWrapping="Wrap" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
When i launch the app list1 is well displayed but when i click "buttonthisyear no change appears
Thanks
Continue reading...
It's an uwp blank application i use a listwiew to display a list of data
The list is display but one time ,if i update the list ,changes are not displayed
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 Property thedate() As String
Get
Return hdate
End Get
Set(ByVal value As String)
value = hdate
End Set
End Property
Public Property civildate() As String
Get
Return civild
End Get
Set(ByVal value As String)
value = civild
End Set
End Property
Public name As String
Public hdate As String
Public civild As String
End Class
The Blank Page item template is documented at C#, VB, and C++ project templates for Store apps
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
data.hdate = Date.Now.ToLongDateString
data.civild = Date.Today.ToShortDateString
list1.Add(data)
Next
End Sub
Private Sub showlist()
Dim myBind As Binding = New Binding()
myBind.Source = list1
myBind.Mode = BindingMode.OneWay
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
The 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" />
<TextBlock x:Name="thedate" Text="{Binding thedate}"
Margin="270,-26,0,0"
FontSize="20"
FontStyle="Normal"
Foreground="DarkSlateBlue"
FontWeight="Bold" FontFamily="Calibri"
HorizontalAlignment="Left" VerticalAlignment="Center"
Padding="0,2,0,0" TextWrapping="Wrap" />
<TextBlock x:Name="civildate" Text="{Binding civildate}"
Margin="90,-26,0,0"
FontSize="20"
FontStyle="Normal"
FontWeight="Bold"
Foreground="DarkSlateBlue" FontFamily="Calibri" HorizontalAlignment="Left" VerticalAlignment="Center"
Padding="0,0,0,0" TextWrapping="Wrap" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
When i launch the app list1 is well displayed but when i click "buttonthisyear no change appears
Thanks
Continue reading...