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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:40:35+00:00 2026-06-17T16:40:35+00:00

In setting up data binding for Observable Collection , under the following context: Implementing

  • 0

In setting up data binding for Observable Collection , under the following context: Implementing CollectionChanged Handler in XAML with WPF all bindings are working correctly, but I’m finding that in addition to changing the Property defined by ItemsSource within the ListBox, I am having to manually update the UI’s visual container with code similar to:

XAML:

<Grid DataContext="{Binding ElementName=PollPublicStockMainWindow}">
        <ListBox Height="132" HorizontalAlignment="Left" Name="lbFiles" 
                 VerticalAlignment="Top" Width="167" 
                 Margin="{StaticResource ConsistemtMargins}"  
                 ItemsSource="{Binding LbItems}">
            <ListBox.InputBindings>
                <KeyBinding Key="Delete" Command="local:MainWindow.DeleteEntry"/>
            </ListBox.InputBindings>
        </ListBox>
</Grid>

CodeBehind:

public partial class MainWindow : Window 
{
    public MainWindow() 
    {
        InitializeComponent();
        LbItems = new ObservableCollection<string>();
        LbItems.CollectionChanged += lbFiles_CollectionChanged;
    }

    private void lbFiles_CollectionChanged(object sender, 
         System.Collections.Specialized.NotifyCollectionChangedEventArgs e) 
    {
        MemoryPersistentStorageBridge memBridge = GetPersistentStorageBridge;
        List<string> newFileList = new List<string>();

        foreach (string str in LbItems) {
            DoSomethingWithNewString(str); //these 2 lines are always paired?  
            lbFiles.Items.Add(str); // this should NOT be needed 
         }
    }
}

Am I missing a binding?

  • 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-17T16:40:37+00:00Added an answer on June 17, 2026 at 4:40 pm

    Do you fire PropertyChanged when LbItems is set? It does not look that way. In the constructor, you call InitializeComponent first and then initialize the collection in LbItems = new ObservableCollection<string>();. I think that your collection is initialized “too late”, because the binding will already have been processed. If you do not fire a property changed when LbItems is set then the binding will not be updated to actually bind to the collection.

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

Sidebar

Related Questions

I am currently setting the connection string for my linq to sql data context
I am trying to do data binding in WPF on a data grid using
If I turn off automatic updating of a binding data source by setting DataSourceUpdateMode
I'm data-binding a ListView to a collection that comes from a service layer. In
I have just started using WPF and am having trouble data binding from the
I'm new to data-binding and I am having a hard-time setting it up for
I am working with MODO python scripts. I imported the MODO setting data into
I'm setting two data values on an image using HTML5 data attributes. jQuery 1.5.2
When setting up a UITableView's data source, I'd be interested to get views on
I'm setting up a simple list view with no real data being populated to

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.