Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding and updating a databound listbox C# windows phone
    primarykey
    data
    text
    <p>I hope this question isnt to dumb, I've tried to search for a solution for 5hours, and mostly found helpfull stuff on this site, but I can not manage to fix my problem.</p> <p>I have my Item Class with just this property:</p> <pre><code>public string ItemName { get; set; } </code></pre> <p>And a Class to hold Items:</p> <pre><code>public class ShoppingListItems { public static List&lt;Item&gt; ItemCollection { get; set; } public ShoppingListItems() { ItemCollection = new List&lt;Item&gt;(); AddAnItem("test"); } public static void AddAnItem(string name) { ItemCollection.Add(new Item() { ItemName = name }); } } </code></pre> <p>And in my XAML file, binding related code is:</p> <pre><code> xmlns:application="clr-namespace:ShoppingListTest" &lt;Grid.Resources&gt; &lt;application:ShoppingListItems x:Key="ShoppingListItems" /&gt; &lt;/Grid.Resources&gt; &lt;Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" DataContext="{StaticResource ShoppingListItems}"&gt; &lt;ListBox x:Name="listBox1" Height="Auto" ItemsSource="{Binding ItemCollection, Mode=TwoWay}"&gt; &lt;TextBlock x:Name="textBlock1" Text="{Binding ItemName}" FontSize="50" /&gt; </code></pre> <p>And then in my MainPage.xaml.cs, in a method on KeyDown I have:</p> <pre><code>ShoppingListItems.AddAnItem(textBox1.Text); </code></pre> <p>The list works great, and shows "test" in the listBox, but adding to the list does not work, I have tried to look at some NotifyPropertyChanged stuff, without any luck.</p> <p>Any idea on what I need to do to update the listBox? I would be soooo glad if anyone had some tips that would make this work!</p>
    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