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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:52:55+00:00 2026-06-14T00:52:55+00:00

private ObservableCollection<ProjectItem> _projectItems; public ObservableCollection<ProjectItem> DataItems { get { return _projectItems; } } public

  • 0
private ObservableCollection<ProjectItem> _projectItems;

public ObservableCollection<ProjectItem> DataItems
    {
        get { return _projectItems; }
    }

public ProjectsPanelViewViewModel()
    {
        _projectItems = new ObservableCollection<ProjectItem>();
        _createProjectCommand = new DelegateCommand(OnCreateProjectCommand);
        _saveProjectCommand = new DelegateCommand(OnSaveProjectCommand);
    }

private void OnCreateProjectCommand()
    {
        _addProjectViewModel = new AddProjectViewModel();
        AddProjectView view = new AddProjectView();
        view.Show();
    }

    private void OnSaveProjectCommand()
    {
        ProjectItemViewModel _vm = new ProjectItemViewModel();
        _vm.ProjectName = ProjectName;
        _vm.ProjectDescription = ProjectDescription;
        var item = new ProjectItem(_vm);
        _projectItems.Add(item);
    }

XAML

<UserControl.DataContext>
    <VM:ProjectsPanelViewViewModel/>
</UserControl.DataContext>
<StackPanel Name="ProjectsPanel" Style="{DynamicResource FullLengthPanelStyle}" >
    <StackPanel Name="ProjectsHeader" Orientation="Horizontal" Margin="0,0,0,5">
        <Label Style="{StaticResource TitleLabelStyleBlue}">projects</Label>
        <Button Name="AddProjects" Margin="10,5,0,0" Style="{StaticResource CircularGreyButtonStyle}" Content="+" ToolTip="Add a new project" Command="{Binding CreateProjectCommand}"/>
        <Button Name="ExpandProjects" Margin="10,5,0,0" Style="{StaticResource CircularGreyButtonStyle}" Content=">" ToolTip="Expand projects"/>
    </StackPanel>

    <ScrollViewer VerticalScrollBarVisibility="Visible">
            <ItemsControl ItemsSource="{Binding DataItems}"/>
    </ScrollViewer>
</StackPanel>

When the OnCreateProjectCommand Opens it creates a window with 2 string fields, this then has a button that executes the OnSaveProjectCommand. The commands are executed fine, however the UI does not pick up that the new item has been added to the collection. (When debugging it is in there). If however you change the code from the OnSaveProjectCommand and put it into the OnCreateProjectCommand, and hardcode the simple string values, the UI is updated correctly from the observable collection.

Can anyone give me some guidance as to why this is not working, and also the correct way that I should be spawning up a new window from this command. Should this be done with State Based view navigation from prism? We are already using this for modularisation and commanding.

Thanks for the advice.

  • 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-14T00:52:56+00:00Added an answer on June 14, 2026 at 12:52 am

    I think you might have a reference problem there. How do you glue this ViewModels with each other? I’m not familiar with Prism, but it might happen that the VM instance you are viewing on screen is not the same as the one you’re debugging. Otherwise it doesn’t make sense. Observablecollections usually work just fine, unless you’re manipulating them from different threads other than the UI thread. Try using Snoop to spy into the running application to see what your DataContexts are.

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

Sidebar

Related Questions

I have a collection private ObservableCollection<ContentItemViewModel> _contentTree; public ObservableCollection<ContentItemViewModel> ContentTree { get { return
So i have something along the lines of private ObservableCollection<ViewModel> _internal; public ObservableCollection<ViewModel> BoundInternal{get;set};
Imagine the following: class Repository { private ObservableCollection<ModelClass> _allEntries; public ObservableCollection<ModelClass> AllEntries { get
Lets have a class: public partial class MyControl: UserControl{ private ObservableCollection<string> names = new
Well, I have the following class definitions: private ObservableCollection<Node> _Nodes; public ObservableCollection<Node> Nodes {
I have a collection similar to: Public Class MyCollection Inherits ObservableCollection(Of MyCollection) Private _Name
private final List<KeyListener> keyListeners= new CopyOnWriteArrayList<KeyListener>(); public void addKeyListener(KeyListener keyListener){ keyListeners.add(keyListener); } In the
I have a two classes: public class ScheduleViewModel : NotificationObject { private ObservableCollection<RecordingsCollection> _collection
In my code I have the two following collections: private ObservableCollection<Job> listOfJobs1 = new
I have a collection in my C# code private ObservableCollection<UserForms> _userForms = new ObservableCollection<UserForms>();

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.