Hi,
I have a server program accepting clients. When a server event occurs the function UpdateClientList() is called.
The function needs to populate the Listview (lsClients) with all the clients.
.vb code
But this doesn't seem to work.
How can I easily show the sessions in the ListView?
Any info at all would be appreciated. I'm totally new to WPF and the data biding is making my head spin...
I have a server program accepting clients. When a server event occurs the function UpdateClientList() is called.
The function needs to populate the Listview (lsClients) with all the clients.
VB.NET:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="500" Width="850" Loaded="Window_Loaded" Initialized="Window_Initialized">
<Grid>
<TabControl HorizontalAlignment="Left" Height="460" VerticalAlignment="Top" Width="832" TabStripPlacement="Left" SelectionChanged="TabControl_SelectionChanged">
<TabItem Header="TabItem" Width="120" Margin="0,0,0,-27">
<ListView x:Name="lvClients" Margin="20,0,17,138">
<ListView.View>
<GridView>
<GridViewColumn Width="80" Header="status"/>
<GridViewColumn Width="80" Header="SessionID"/>
<GridViewColumn Width="80" Header="MachineID"/>
</GridView>
</ListView.View>
</ListView>
</TabItem>
<TabItem Header="TabItem" Width="120" Height="50" Margin="0,28,0,-28">
<Button Content="Button" Height="100" Width="75" Margin="279,326,346,24" Click="Button_Click"/>
</TabItem>
</TabControl>
</Grid>
</Window>
.vb code
VB.NET:
Private Sub UpdateClientsList()
InitializeComponent()
Dim sessionList As List(Of TcpComm.Server.SessionCommunications) = server.GetSessionCollection()
Dim lvi As ListView
Me.lvClients.Items.Clear()
For Each session As TcpComm.Server.SessionCommunications In sessionList
lvi = New ListView
lvi.Items.Add(session.sessionID.ToString())
lvi.Items.Add(session.machineId)
Me.lvClients.Items.Add(lvi)
Next
End Sub
But this doesn't seem to work.
How can I easily show the sessions in the ListView?
Any info at all would be appreciated. I'm totally new to WPF and the data biding is making my head spin...