Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>ListView.ItemsSource</code> property can bind to one collection item. So, there is no direct way to achieve this. But, you can create a class that encapsulates all the values you want to display in the ListView. Then create an ObservableCollection and bind it to the ListView.ItemSource.</p> <p>Note: You can achieve this in much cleaner way if you follow any UI patterns. However, just to keep it simple</p> <pre><code>/// &lt;summary&gt; /// Interaction logic for MainWindow.xaml /// &lt;/summary&gt; public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); _dataItems = GetDataItems(); DataContext = this; } private ObservableCollection&lt;Combination&gt; GetDataItems() { //Here load all of your individual data structure //Eg var items = new List&lt;Combination&gt; { new Combination(new Bank {AccountNo = 112, AccountName = "somename"}, new Cheque {ChequeDate = DateTime.Now, ChequeNo = 234562}), new Combination(new Bank {AccountNo = 132, AccountName = "name"}, new Cheque {ChequeDate = DateTime.Now, ChequeNo = 215562}), new Combination(new Bank {AccountNo = 212, AccountName = "someother"}, new Cheque {ChequeDate = DateTime.Now, ChequeNo = 114562}) }; return new ObservableCollection&lt;Combination&gt;(items); } private ObservableCollection&lt;Combination&gt; _dataItems; public ObservableCollection&lt;Combination&gt; DataItems { get { return _dataItems; } set { _dataItems = value; } } } public class Combination { public Combination(Bank bk, Cheque cq) { ChequeNo = cq.ChequeNo; ChequeDate = cq.ChequeDate; AccountName = bk.AccountName; AccountNo = bk.AccountNo; } public int ChequeNo { get; set; } public DateTime ChequeDate { get; set; } public int AccountNo { get; set; } public String AccountName { get; set; } } public class Cheque { public int ChequeNo { get; set; } public DateTime ChequeDate { get; set; } } public class Bank { public int AccountNo { get; set; } public String AccountName { get; set; } } </code></pre> <p>And finally bind it to your ListView</p> <pre><code>&lt;Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:WpfApplication1="clr-namespace:WpfApplication1" Title="MainWindow" Height="350" Width="525"&gt; &lt;Grid&gt; &lt;ListView x:Name="lvac" HorizontalAlignment="Left" ItemsSource="{Binding Path=DataItems}" VerticalAlignment="Top"&gt; &lt;ListView.View&gt; &lt;GridView&gt; &lt;GridViewColumn Width="100" Header="Cheque Num" DisplayMemberBinding="{Binding Path=ChequeNo}" /&gt; &lt;GridViewColumn Width="100" Header="Ch. date" DisplayMemberBinding="{Binding Path=ChequeDate}" /&gt; &lt;GridViewColumn Width="100" Header="Account Name" DisplayMemberBinding="{Binding Path=AccountName}" /&gt; &lt;GridViewColumn Width="100" Header="Account No" DisplayMemberBinding="{Binding Path=AccountNo}" /&gt; &lt;/GridView&gt; &lt;/ListView.View&gt; &lt;/ListView&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>So the result would be something like below <img src="https://i.stack.imgur.com/EmTwE.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload