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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:21:00+00:00 2026-05-17T02:21:00+00:00

hey. I’m trying to maintain an MVVM model, but am tripping up somewhere when

  • 0

hey. I’m trying to maintain an MVVM model, but am tripping up somewhere when trying to bind to a listbox. The first time I run the application, I set ItemCatalog (ObservableCollection) to be a certain ObservableCollection list. The listbox is empty, but if I try again it works. However, there is a lag between the datasource and the displayed data. For example,

I load the app -> set source to X -> Listbox is empty

I now set source to Y -> Listbox displays X

I set source to Z -> Listbox displays Y etc..

This, to me, implies the binding is working but I can’t figure out why it’s lagging by one.

My XAML looks like this:

<ListBox ItemsSource="{Binding ItemCatalog}">
       <DataTemplate>
             <StackPanel Margin="0,0,0,17" Width="432">
                  <TextBlock Text="{Binding Ref}" TextWrapping="Wrap"  Foreground="Black" />
                  <TextBlock Text="{Binding ItemName}" TextWrapping="Wrap" Margin="12,-6,12,0" Foreground="Black" />
             </StackPanel>
       </DataTemplate>
</ListBox>

In the ViewModel, the value of ItemCatalog is based on whichever button the user pressed (X,Y,Z), which are all stored in a static variable. Is there a reason there’s a delay, or a way to force it to rebind to the latest ItemCatalog value?

If I remove the binding from the XAML and set the listbox source straight from the code-behind, it works perfectly. However, I want to try and maintain the XAML coding. I’m new to MVVM so I might be doing this the wrong way round. thanks

EDIT – extra code

The code is changed in the OnNavigatedTo method

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {


            if (NavigationContext.QueryString["Category"].ToString() == "House")
            {
                _categoryType = Models.House;

            }
            if (NavigationContext.QueryString["Category"].ToString() == "Car")
            {
                _categoryType = Models.Car;

            }

            MyViewModel.LoadNewData(_categoryType);


            base.OnNavigatedTo(e);
        }

LoadNewData method just sets the static variable based on the parameter passed.

   ItemCatalog = App.CarCatalog;

Essentially, I need to rebind after the page has loaded, via XAML.

  • 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-17T02:21:01+00:00Added an answer on May 17, 2026 at 2:21 am

    At guess (since there still isn’t really enough code to go on) your ViewModel is raising a property change even before the field backing ItemCatalog is actually assigned. Something like:-

     ObservableCollection<Stuff> _ItemCatalog;
     ObservableCollection<Stuff> ItemCatalog 
     {
    
        get { retutn _ItemCatalog; }
        set
        {
           PropertyChanged("ItemCatalog");
           _ItemCatalog = value;
        }
     }
    

    This might result in the behaviour you describe.

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

Sidebar

Related Questions

Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my
Hey having some trouble trying to maintain transparency on a png when i create
Hey so what I want to do is snag the content for the first
Hey, I've been developing an application in the windows console with Java, and want
Hey everyone, I'm using Virtual PC and working with a virtual hard disk (*.vhd)
Hey, I'm using Levenshteins algorithm to get distance between source and target string. also
Hey all, my Computational Science course this semester is entirely in Java. I was
Hey peoples, I've been studying Java for a couple of weeks, and have decided
Hey right now I'm using jQuery and I have some global variables to hold
Hey, in the Programming Pearls book, there is a source code for setting, clearing

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.