Note that there are some explanatory texts on larger screens.

plurals
  1. POBinding ListView not Binding
    primarykey
    data
    text
    <p>I have a problem trying to bind my list to list view and I get an empty list view. I have tried changining my list to a property as I have seen this solve other peoples problem with no luck, any help appreciated.</p> <p>Here is the XAML</p> <pre><code>&lt;Window x:Class="key_stage_level_2_app.Window7" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" DataContext="{Binding RelativeSource={RelativeSource Self}}" Title="Window7" Height="600" Width="800" Loaded="Window_Loaded"&gt; &lt;Grid&gt; &lt;TabControl Height="536" HorizontalAlignment="Left" Name="tabControl1" VerticalAlignment="Top" Width="778"&gt; &lt;TabItem Header="Results2" Name="tabItem2"&gt; &lt;Grid&gt; &lt;ListView Height="323" HorizontalAlignment="Left" Margin="107,96,0,0" Name="listView2" VerticalAlignment="Top" Width="186" ItemsSource="{Binding Path=someList}" &gt; &lt;ListView.View&gt; &lt;GridView&gt; &lt;GridViewColumn Width="80" Header="Name" DisplayMemberBinding="{Binding Path=Name}"/&gt; &lt;GridViewColumn Width="80 " Header="Result" DisplayMemberBinding="{Binding Path=Result}"/&gt; &lt;/GridView&gt; &lt;/ListView.View&gt; &lt;/ListView&gt; </code></pre> <p>Here is the code behind </p> <pre><code>namespace key_stage_level_2_app { /// &lt;summary&gt; /// Interaction logic for Window7.xaml /// &lt;/summary&gt; public partial class Window7 : Window { App app = (App)App.Current; private List&lt;Pupil&gt; someList { get; set; } public Window7() { someList = new List&lt;Pupil&gt;(); foreach (Pupil pupil in app.PupilList) { someList.Add(pupil); } someList.Add(new Pupil { Name = "Simon", Result = 100, Grade = 100.00, ExtensionWork = true, TakenTest = true }); Console.WriteLine("someList size = " + someList.Count); InitializeComponent(); } </code></pre> <p>And the Class</p> <pre><code>class Pupil { public String name; int result; double grade; bool extensionWork; bool takenTest; public Pupil(String Pname, int Presult, double Pgrade, bool PextensionWork, bool PtakenTest) { Name = Pname; Result = Presult; Grade = Pgrade; ExtensionWork = PextensionWork; TakenTest = PtakenTest; } public Pupil() { } public String Name { get { return name; } set { name = value; } } public int Result { get { return result; } set { result = value; } } public double Grade { get { return grade; } set { grade = value; } } public bool ExtensionWork { get { return extensionWork; } set { extensionWork = value; } } public bool TakenTest { get { return takenTest; } set { takenTest = value; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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