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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:22:21+00:00 2026-05-25T00:22:21+00:00

I have a ViewModel class that looks like this. class MyViewModel : Screen {

  • 0

I have a ViewModel class that looks like this.

class MyViewModel : Screen
{
  public BindableCollection<MyObject> MyObjects { get; set; }

  private MyObject selectedObject;
  public MyObject SelectedMyObject
  {
    get { return selectedObject; }
    set
    {
      selectedObject = value:
      //some additional unrelated logic
    }
  }

  public void SaveObject()
  {
    //some logic
  }
  public bool CanSaveObject{
    get{
      //logic to determine if the selectedObject is valid
    }
  }

That is the relevant code. Now the problem.

MyObject is a class with three properties. In the View I have a ListView that is bound to the MyObjects collection, and three TextBoxes that are bound to the SelectedItem in the ListView.

When I fill in the textboxes, the related object gets changed in the Model, but I want to make sure that the object is in a valid state before you can save it. CanSaveObject has the necessary logic, but the problem is that is never gets called since I don’t have any oppurtunity to call NotifyOfPropertyChanged when the textboxes are filled since only the properties of selectedObject are called, and no properties on MyViewModel.

So the question is: Are there any good way to do this without making properties on the ViewModel that encapsulate the properties inside MyObject.

I have got it working if I make properties like these, and then bind to these instead of the SelectedItem directly in the view, but the viewmodel gets cluttered up in the hurry if hacks like this is the only way to do it. I hope it’s not 🙂

public string SelectedObjectPropertyOne{
  get{ return selectedObject.PropertyOne; }
  set{
    selectedObject.PropertyOne = value;
    NotifyOfPropertyChange(() => SelectedObjectPropertyOne);
    NotifyOfPropertyChange(() => CanSaveObject);
  }
}
  • 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-25T00:22:22+00:00Added an answer on May 25, 2026 at 12:22 am

    ActionMessage.EnforceGuardsDuringInvocation is a static boolean field that can be set to enforce a guard check when an action is about to be invoked. This will guard the actual Save action from being invoked, however it will not help with the issue of the UI appearance based on the guard state immediately after an update to the selected model.

    Without doing that, the only other modification I could suggest would be to create a VM type for MyObject model and move the validation and save logic there. This would also allow you to simplify your Views…

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

Sidebar

Related Questions

I'm new to MVVM. I have a label in my view that looks like
Say I have a POCO that stores a date range as follows: public class
This behavior is making me wonder about my sanity.. I have a form that
I saw a similar post that was trying to do this same thing with
This is probably a very simple question, but at this time I have myself
I have an 'ObservableCollection' that stores formatted ColumnLabels that need pasting into DataGrid. The
I may be confused about the purpose behind INotifyPropertyChanged and Silverlight... I have XAML
Update After a bit of investigating. What seems to be the issue is that
I can't for the life of me figure out why this doesn't work. I've
How do I get properties in my BLL passed down to a ModeView. For

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.