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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:04:11+00:00 2026-05-26T12:04:11+00:00

I have a problem updating the layout of my listbox using MVVM with Prism

  • 0

I have a problem updating the layout of my listbox using MVVM with Prism 4.0.

I have no problem displaying my observablecollection to my listbox, but when I bind it to the DelegateCommand to add a new user or update a selected listbox item, it doesn’t update but the underlying object is being updated. I tried using MessageBox.Show to give me the recent output and it did the changes, but in the view.xaml it doesn’t update.

public class ProfileViewModel : DependencyObject
{
 public DelegateCommand SaveCommand { get; set; }
 public ObservableCollection<Persons> Persons { get; set; }

 public ProfileViewModel()
 {
   CreatePerson();
   SaveCommand = new DelegateCommand(Save,CanSave);
 }

 private void Save()
 {
   Person[0].LastUpdated = DateTime.Now
   Persons.Add(new Persons { FIrstName = "Bob", LastName "Bob," LastUpdated=DateTime.Now});
 }

 private bool CanSave()
 {
  return true;
 }

 public void CreatePerson()
 {
   this.Persons = new ObservableCollection<Persons>();
   Persons.Add(new Persons { FirstName = "John", LastName = "Doe", LastUpdated = DateTime.Now});Persons.Add(new Persons { FirstName = "John", LastName = "Doe", LastUpdated = DateTime.Now});
Persons.Add(new Persons { FirstName = "John", LastName = "Doe", LastUpdated = DateTime.Now});
 }
}
}

ProfilePage.Xaml

<ListBox ItemsSource="{Binding Persons}" Name="ListBoxItem">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical">
                            <TextBlock Text="{Binding FirstName}"/>
                            <TextBlock Text="{Binding LastName}" />
                            <Button Content="_Save" Command={Binding Source={Static Resource ProfileViewModel{, Path=SaveCommand}" />
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

ProflilePage.xaml.cs

 public partial class ProfilePage : Window
 {
   private ProfileViewModel _vm;

   [Dependency]
   public ProfileViewModel VM
   {
     set { _vm = value; this.DataContext = _vm; }
   }

   public ProfilePage()
   {
     InitializeComponent();
   }

App.xaml.cs

protected override void OnStartup(StartupEventArgs e)
 {
   IUnityContainer container = new UnityContainer();
   ProfileViewModel source = new ProfileViewModel();
   ProfilePage window = container.Resolve<ProfilePage>();
   window.show();
 }

My Persons class implements the INotifyPropertyChanged and has a getter setter of LastName,FirstName and LastUpdated.

  • 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-26T12:04:12+00:00Added an answer on May 26, 2026 at 12:04 pm

    I am pretty sure you need the DataContextProxy to make bindings working. The ElementName binding will also work on ListBox

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

Sidebar

Related Questions

I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have a problem when updating the source of an ASP ListBox in an
hey , I have a problem with updating a record using a domain service,
I have problem with updating my datagridview after inserting new data to table. It
I am using EF 4.1 code first and have problem updating Order entity, when
Have a problem with updating an existing record of my DB. In my view
i have a problem with updating my textview. i am making a c2dm app.
I have a little problem in updating date. My first table is DONOR donor-nic----username-----status
I have problem with displaying adsense ads in ie7 google adsense adds an iframe
i have problem to correctly bind data to WPF Chart. When i'm setting ItemsSource

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.