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

  • SEARCH
  • Home
  • 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 4101356
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:41:11+00:00 2026-05-20T20:41:11+00:00

I have the following XAML: … <ListBox Name =RoomsListBox Height=100 HorizontalAlignment=Left Margin=12,41,0,0 VerticalAlignment=Top Width=120></ListBox>

  • 0

I have the following XAML:

 ...
 <ListBox Name ="RoomsListBox" Height="100"
 HorizontalAlignment="Left" Margin="12,41,0,0"
 VerticalAlignment="Top" Width="120"></ListBox>
 ...   

And the following C#-code:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
     RoomsListBox.ItemsSource = new[] { new { Name = "First1" },
       new { Name = "First2" } };
     RoomsListBox.DisplayMemberPath = "Name";
}

The problem is that my ListBox have items but they are empty. Why I don’t see “First1” and “First2” instead?

  • 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-20T20:41:12+00:00Added an answer on May 20, 2026 at 8:41 pm

    The issue here isn’t with the bindings nor the ItemTemplate nor the change notification. It’s the Anonymous Type you’re using that’s causing it. try using a class or struct for your items

    public class Item
    {
        public string Name { get; set; }
    }
    
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        RoomsListBox.ItemsSource = new[] { 
                                            new Item { Name = "First1" },
                                            new Item { Name = "First2" }};
        RoomsListBox.DisplayMemberPath = "Name";
    }
    

    your xaml stays the same, or you can define a DataTemplate for the ListBox items if you want. Note that you can’t set both the ItemTemplate and DisplayMemberPath at the same time (one has to be null). Also, make sure that the class representing your items has to be public.

    Hope this helps 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created two buttons using the following XAML code. <Button x:Name=Button1 Width=100 Content=Button1
I have the following XAML Code: <sdk:DataGrid Margin=58,8,52,18 Name=dataGridTickets> <sdk:DataGrid.Columns> <sdk:DataGridTextColumn x:Name=ticketNoColumn Header=Ticket No.
I have the following xaml for the MS Bing Maps control. ZoomLevel is bound
I Have a ResourceDictionary Generic.xaml which consists of a set of other resource dictionaries,
Suppose I have 3 fields on a Silverlight based xaml page Color, Size and
I am developing silverlight application. I have a listbox in my application. I am
I have following target in mz ant script to build my java application <target
I'm a newbie with WPF and c# and have a (probably very simple) problem.
I am using the silverlight 4 toolkit gridcontrol and I'm using auto generated columns.
I'm trying to rehost the WF4 Workflow Designer. In the Imports tab, I'd like

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.