im trying to bind a list-view with a generic list but it seems im doing something wrong.
this is my collection
public ObservableCollection<SharedFile> searchResults;
this is the SharedFile Class
public class SharedFile
{
public string FileName { get; set; }
public long FileSize { get; set; }
public string FileLocation { get; set; }
public string Extention { get; set; }
public IPAddress publicFileIpAdress { get; set; }
public IPAddress privateFileIpAdress { get; set; }
public string FileUserName { get; set; }
}
this is my xaml
<ListView Name="lsbSearchBox" Grid.Row="1" ItemsSource="{Binding Path=searchResults,ElementName=SearchPageRoot}">
<ListView.View>
<GridView>
<GridViewColumn Width="340" Header="File Name" DisplayMemberBinding="{Binding FileName}" />
<GridViewColumn Width="140" Header="Size" DisplayMemberBinding="{Binding FileSize}"/>
<GridViewColumn Width="140" Header="User Name" DisplayMemberBinding="{Binding FileName}"/>
</GridView>
</ListView.View>
</ListView>
after hitting the “search” button im filling the collection with data and at the end im setting the datacontext (but nothing happens)
lsbSearchBox.DataContext = this;
What am i doing wrong here ?
From here:
Make
searchResultsas public property.