TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
John
NA
3
0
ListView not displaying observablecollection
Mar 4 2012 12:16 PM
XAML:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="Rocking Robin" Height="350" Width="525">
<Grid>
<DockPanel>
...
<ListView Name="lvLibrary" ItemsSource="{Binding _SongLibrary}">
<ListView.View>
<GridView>
<GridViewColumn Width="120" Header="Title" DisplayMemberBinding="{Binding Title}"></GridViewColumn>
<GridViewColumn Width="120" Header="Artist" DisplayMemberBinding="{Binding Artist}"></GridViewColumn>
<GridViewColumn Width="120" Header="Album" DisplayMemberBinding="{Binding Album}"></GridViewColumn>
<GridViewColumn Width="0" Header="FileName" DisplayMemberBinding="{Binding FileName}"></GridViewColumn>
</GridView>
</ListView.View>
</ListView>
...
</Window>
And code:
Class MainWindow
Public _SongLibrary As ObservableCollection(Of ASong)
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnLoad.Click
Dim ofd As New Microsoft.Win32.OpenFileDialog
ofd.Filter = "MP3 Files (*.mp3)|*.mp3"
If ofd.ShowDialog = True Then
Dim Sng As New ASong
Sng.FileName = ofd.FileName
Sng.Title = InputBox("Enter Title", "Title", "Default Title")
Sng.Artist = InputBox("Enter Artist", "Artist", "Default Artist")
Sng.Album = InputBox("Enter Album", "Album", "Unknown")
_SongLibrary.Add(Sng)
End If
End Sub
Public Sub New()
' Add any initialization after the InitializeComponent() call.
_SongLibrary = New ObservableCollection(Of ASong)
End Sub
End Class
The play event fires, but there's nothing displayed.
Reply
Answers (
0
)
DataGridComboBoxColumn in DataGrid
System date and time