|
-
Feb 9th, 2010, 03:09 AM
#1
Thread Starter
Addicted Member
Binding Object array to ListView
First of all, this will be my first WPF project (Kinda late, I know -.-). Having done some work with Windows Forms and ASP, thought I would try this out as well. The objective is to make a trendy, better-looking UI for managing Windows Services on a single host machine, much like the old MS Management Console for Windows services on Windows XP.
So, I am trying to list all installed services in a Listview. (If there is a better way to show the list, please enlighten me.) Getting the list of all installed services is easy with System.ServiceProcess.ServiceController.GetServices() method. It returns an Array of ServiceController objects, each representing one installed Windows service on the host machine.
But, getting that array onto the ListView is giving me trouble. I have read somewhere that it is advisable to bind the collection directly to the listview. For some reason, I am not being able to make it work as I would like it to.
Here is the XAML:
Code:
<ListView Grid.Column="1" Grid.Row="1" Name="ServicesLVW" ItemsSource="{Binding Services}">
<ListView.View>
<GridView>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding DisplayName}" />
<GridViewColumn Header="Status" DisplayMemberBinding="{Binding Path=Status}" />
<GridViewColumn Header="Service Type" DisplayMemberBinding="{Binding Path=ServiceType}" />
</GridView>
</ListView.View>
</ListView>
Here is the VB Code:
vb.net Code:
Imports System.ServiceProcess
Imports System.Collections.ObjectModel
Partial Public Class Window2
Public _services() As ServiceController
Public ReadOnly Property Services() As ServiceController()
Get
Return _services
End Get
End Property
Public Sub New()
_services = ServiceController.GetServices
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
End Class
I know there is something wrong, but this being my first project in WPF, I can't seem to put my finger on where or what. Please advise. All and any suggestions will be much appreciated. Thanks in advance
Anyone who has never made a mistake has never tried anything new. - Einstein
 Peace! 
-
Feb 9th, 2010, 10:04 PM
#2
Thread Starter
Addicted Member
Re: Binding Object array to ListView
28 views and no response...*crosses fingers* I hope someone would point me in the right direction Q__Q
Anyone who has never made a mistake has never tried anything new. - Einstein
 Peace! 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|