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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:05:58+00:00 2026-05-21T20:05:58+00:00

I already have succesfully used MVVM principles in former projects, but i’m stuck with

  • 0

I already have succesfully used MVVM principles in former projects, but i’m stuck with something … very basic!

Using EF4.1 (code first approach) as my data storage access which works fine. Created the following class:

public class Photo
    {
        [Key]       
        public int PhotoId { get; set; }
        public string Year { get; set; }
        public byte[] Thumbnail { get; set; }
        public DateTime InsertTime { get; set; }     //insertion time
        public DateTime UpdateTime { get; set; }     //last modification time


        //navigational properties
        public virtual Image Image { get; set; }
        public virtual Monument Monument { get; set; }//a Photo belongs to a specific Monument
        public virtual MDPremisesSpace MDPremisesSpace { get; set; } //a Photo was shot at specific premises space
        public virtual MDRestauration MDRestauration { get; set; }//a Photo has a restauration
        public virtual MDMaintenance MDMaintenance { get; set; }//a Photo has a maintenance
        public virtual MDType MDType{ get; set; }//a Photo has a type
        public virtual User InsertUser { get; set; }    //the user who inserted this reocord
        public virtual User UpdateUser { get; set; }   //the user who lastly modified this reocord

        //constructor
        public Photo()
        {            
        }
    }

Created a Viemodel based on that class (i ‘m using a Viewmodel based on generics, to resuse it whereever i can – with success), which implements INotifyPropertyChanged.In this viewmodel there is also a Property called Monuments which is defined this way (works fine):

private ObservableCollection<Model.Monument> monuments = new ObservableCollection<Model.Monument>();
public ObservableCollection<Model.Monument> Monuments
{
            get { return monuments; }
            private set { monuments = value; }

}

Created a view in which i used a combobox like this:

<ComboBox Name="cmbMonument" Grid.Row="1" Grid.Column="1" Width="200" HorizontalAlignment="Left"
                      ItemsSource="{Binding  Path=Monuments }"  
                      SelectedItem="{Binding Path=SelectedRecord.Monument,Mode=TwoWay,  UpdateSourceTrigger=PropertyChanged}"                       
                      DisplayMemberPath="Name"
                      />

The values are showing up correclty (and they can also be saved correctly).

BUT:

Is there anyone who can explain why changing the selected item in the combobox, it DOES NOT raise a property change notification??

If i would change the Year property the notification would get raised!!

(i’m suspecting the fact that the Monument property in the Photo class above is a navigational property…but even if it is like that, shouldn’t it raise a notification?)

Any hints are mostly welcome!!

  • 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-21T20:05:59+00:00Added an answer on May 21, 2026 at 8:05 pm

    Well it turns out that my suspicions where correct!

    The correct way to declare this kind of code first class in EF4.1 is the following:

    public class Photo
        {
            [Key]
            public int PhotoId { get; set; }
            public int? MonumentId { get; set; }
            public int? MDPremisesSpaceId { get; set; }
            public int? MDRestaurationId { get; set; }
            public int? MDMaintenanceId { get; set; }
            public int? MDTypeId { get; set; }
            public string Year { get; set; }
            public byte[] Thumbnail { get; set; }
            public int? InsertUserId { get; set; }        //the Id of user who inserted this record
            public DateTime InsertTime { get; set; }     //insertion time
            public int? UpdateUserId { get; set; }        //the Id of last user who modified this record
            public DateTime UpdateTime { get; set; }     //last modification time
    
    
    
            //navigational properties
            public virtual Image Image { get; set; }
            [ForeignKey("MonumentId")]
            public virtual Monument Monument { get; set; }//a Photo belongs to a specific Monument
            [ForeignKey("MDPremisesSpaceId")]
            public virtual MDPremisesSpace MDPremisesSpace { get; set; } //a Photo was shot at specific premises space
            [ForeignKey("MDRestaurationId")]
            public virtual MDRestauration MDRestauration { get; set; }//a Photo has a restauration
            [ForeignKey("MDMaintenanceId")]
            public virtual MDMaintenance MDMaintenance { get; set; }//a Photo has a maintenance
            [ForeignKey("MDTypeId")]
            public virtual MDType MDType { get; set; }//a Photo has a type
            [ForeignKey("InsertUserId")]
            public virtual User InsertUser { get; set; }    //the user who inserted this reocord
            [ForeignKey("UpdateUserId")]
            public virtual User UpdateUser { get; set; }   //the user who lastly modified this reocord
    
            //constructor
            public Photo()
            {
            }
        }
    

    Notice that every Foreign Key association has ALSO its property in the class. Now the property change notification takes place!

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

Sidebar

Related Questions

I have used R in the past to do very basic calls to the
I already have my azure web role running in cloud using azure sdk 1.6.
I already have this issue but I cannot remember how to solved it. (I
I have used GTMOAuth to successfully login to dropbox but i dont seem to
I have used MEF to load in external XAPs, this works great. But when
I have already successfully used CCmake to compile dcmtk3.6 and build it in an
I have succesfully installed Doxygen and GraphViz on my mac (running Lion OS), but
i have already succesfully translated some quotes via my translation function __(); and now
We already have the database with real data inside. Now we want to build
i already have a project with TreeNode class which creates a hierachy of nodes

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.