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 8983689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:54:07+00:00 2026-06-15T20:54:07+00:00

<ListBox x:Name=MainList HorizontalAlignment=Left Height=468 Margin=10,10,0,0 VerticalAlignment=Top Width=100 ItemsSource={Binding Items,Mode=TwoWay} DisplayMemberPath=Name/> [Serializable()] public class MYcontainer

  • 0
<ListBox x:Name="MainList" HorizontalAlignment="Left" Height="468" Margin="10,10,0,0" VerticalAlignment="Top" Width="100" ItemsSource="{Binding Items,Mode=TwoWay}" DisplayMemberPath="Name"/>



[Serializable()]
public class MYcontainer : INotifyPropertyChanged,ISerializable
{
    private List<MYClass> _items = new List<MYClass>();
    public List<MYClass> Items
    {
        get{ return _items;}
       set { this._items =value;
        OnPropertyChanged("Items");
    }
public event PropertyChangedEventHandler PropertyChanged;
    public void OnPropertyChanged(string propertyName = null)
    {
        var eventHandler = this.PropertyChanged;
        if (eventHandler != null)
            eventHandler(this, new PropertyChangedEventArgs(propertyName));
    }  
}

When I add an item to “Items” the UI doesn’t update, the binding is working fine, since if I closed the window and opened it again, the new items appear correctly.

What am I doing wrong? I know if I used ObservableCollection it will work fine, but shouldn’t it work with List<>? I already have in another window a string[] property and it update fine.

  • 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-06-15T20:54:09+00:00Added an answer on June 15, 2026 at 8:54 pm

    If you don’t want to ues ObservableCollection you will have to implement INotifyCollectionChanged.

    public partial class MainWindow : Window, INotifyCollectionChanged
    {
    
        public event NotifyCollectionChangedEventHandler CollectionChanged;
    
        public MainWindow()
        {
            InitializeComponent();
        }
    
    
        public void NotifyCollectionChanged(NotifyCollectionChangedAction action)
        {
            if (CollectionChanged != null)
            {
                CollectionChanged(this, new NotifyCollectionChangedEventArgs(action));
            }
        }
    }
    

    However ObservableCollection does all this for you, adding all the same logic to your List<T> would just create a custom ObservableCollection, I see no point in this when MS has alraedy made this for you

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

Sidebar

Related Questions

I have the following XAML: ... <ListBox Name =RoomsListBox Height=100 HorizontalAlignment=Left Margin=12,41,0,0 VerticalAlignment=Top Width=120></ListBox>
<ListBox Height=434 HorizontalAlignment=Left Margin=6,238,0,0 Name=listBox1 VerticalAlignment=Top Width=432 DataContext={Binding}> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text={Binding Name}
I had use listbox.itemsource as my e.Result. <ListBox Height=476 HorizontalAlignment=Left Margin=11,17,0,0 Name=ListBox1 VerticalAlignment=Top Width=434
I have a ListBox simplified to the following XAML <ListBox ItemsSource={Binding Properties} DisplayMemberPath=Name SelectedItem=SelectedProperty
I have the following ListBox with an ItemTemplate <ListBox SelectionMode=Multiple ItemsSource={Binding MyItems} DisplayMemberPath=Name> <ListBox.ItemTemplate>
A have listbox <ListBox> <ListBox.ItemTemplate> <DataTemplate> <DockPanel> <Button Content={Binding name_trainer} Tag={Binding idPersonTrainer} DockPanel.Dock=Top HorizontalAlignment=Center>
my listbox: <ListBox x:Name=listBox Grid.Row=2 FontSize=26 SelectionChanged=listBox_SelectionChanged ItemsSource={Binding SelectedSubGenre.PhotoCollection}> <ListBox.ItemTemplate> <DataTemplate> <Border BorderBrush=BurlyWood BorderThickness=1,1,1,1
I have a listbox on a page: <select id=user_list name=user_list size=21 style=width:200px;> <option value=1>User
I have a horizontal ListBox of items, each of which has two properties: Name
I have a custom listbox. Some of the collections's items have fields "name", "text",

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.