Note that there are some explanatory texts on larger screens.

plurals
  1. POBinding ListBox to List in Silverilght not working
    primarykey
    data
    text
    <p>All,</p> <p>I have what i think is the simplest example possible of data binding in silverlight... but clearly even that is too complicated for me :)</p> <p>The XAML:</p> <pre><code>&lt;UserControl x:Class="SilverlightApplication1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"&gt; &lt;ListBox x:Name="rblSessions"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;TextBlock Text="{Binding SessionTitle}" Foreground="Black" FontSize="30" /&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; </code></pre> <p></p> <p>The code behind:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace SilverlightApplication1 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); List&lt;Sessions&gt; theSessions = makeSessions(); rblSessions.ItemsSource = theSessions; rblSessions.DataContext = theSessions; } public List&lt;Sessions&gt; makeSessions() { List&lt;Sessions&gt; theReturn = new List&lt;Sessions&gt;(); for (int i = 0; i &lt; 20; i++) { Sessions s = new Sessions() { SessionID = i, SessionTitle = string.Format("title{0}", i) }; theReturn.Add(s); } return theReturn; } } public class Sessions { public int SessionID; public string SessionTitle; } } </code></pre> <p>When I run the app, I get a listbox with 20 elements in it, but each element is empty, and only about 5 pixels tall (though I set FontSize to "30")</p> <p>What am I doing wrong? Help please and thanks</p> <p>/jonathan</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