Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 476911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:32:16+00:00 2026-05-13T00:32:16+00:00

All, I have what i think is the simplest example possible of data binding

  • 0

All,

I have what i think is the simplest example possible of data binding in silverlight… but clearly even that is too complicated for me 🙂

The XAML:

<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">
<ListBox x:Name="rblSessions">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding SessionTitle}" Foreground="Black" FontSize="30" />
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

The code behind:

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<Sessions> theSessions = makeSessions();
            rblSessions.ItemsSource = theSessions;
            rblSessions.DataContext = theSessions;

        }

        public List<Sessions> makeSessions()
        {
            List<Sessions> theReturn = new List<Sessions>();
            for (int i = 0; i < 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;
    }
}

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”)

What am I doing wrong? Help please and thanks

/jonathan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T00:32:17+00:00Added an answer on May 13, 2026 at 12:32 am

    You must make your Session class members into properties in order to use them in a binding. This should fix it:

    public class Sessions
    {
        public int SessionID { get; set; }
        public string SessionTitle { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have all the dependancies installed (or I think I do). I definitely have
Dear all,Now i have this question in my java program,I think it should be
I have on my holder (think of it as a relationships table holding all
EDIT: I have fixed all but two warnings now, so thank you all for
I have a form with 2 text boxes that all do the same thing.
I have about 8 entities that all have a one to one relationship with
I have three classes that all have a static function called 'create'. I would
I have placed below the simplest example I could come up with to demonstrate
I have a read statement that expects a number, very simple example code: program
So I want to do the simplest possible thing. Assume I have a MYSQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.