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 :
You can bind to public properties, sub-properties, as well as indexers, of any common language runtime (CLR) object.
You cannot bind to public fields.
Make searchResults
as public property.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.