I am binding WPF with Entity-Framework.
The Window.DataContext property is set to a Quote.
This Quote has a property Job, that I have to trigger Quote.JobReference.Load it should load from the server.
<ContentControl Content="{Binding Job}"
ContentTemplate="{StaticResource JobTemplateSummary}"/>
As you can see above, I am trying to bind a ContentControl to the Window’s DataContext which is a StaticResource Quote class.
I am calling the Load in the Window.Load even handler.
Should I’ve called somewhere else?
The problem was that Navigation Properties don’t call
PropertyChangedevent by default so when the window is bound (which is before Page_Load handler) the JobReference was still not Loaded, we have to callQuote.OnPropertyChanged("Job")explicitly when the job property changes, so the WPF UI knows to refresh the control binding.I added the following to the
Quoteclass, and this solved the problem: