Dispatcher is null after clone

Feb 21, 2013 at 6:51 AM
Edited Feb 21, 2013 at 7:06 PM
I have a code-first entity framework class that I'm trying to use as a model in my project. When I call BeginEdit() in my associated ViewModel and the object is cloned the dispatcher of the new object is null. With the dispatcher being null the NotifyPropertyChanged method throws a NullReferenceException. The exception is being thrown from the BindingHelper line 60.

Anyone have any idea what I'm doing wrong? I've included a simplified version of my class below.
[DataContract(IsReference=true)]

public class Participant : ModelBase<Participant>
{
    [DataMember]
    public int Id { get; set; }

    [DataMember, MaxLength(64)]
    public string Code { get; set; }

    private string _firstName;

    [DataMember, MaxLength(128)]
    public string FirstName
    {
        get { return _firstName; }
        set
        {
            _firstName = value;           
            NotifyPropertyChanged(p => p.FirstName);
       }
    }
}
I'm explicitly defining the DataContract because the class also has some navigation properties that would lead to circular references.
Coordinator
Feb 25, 2013 at 1:58 AM
If this is a WPF app, you need to call UIDispatcher.Initialize from the main UI thread on application startup.
Mar 18, 2013 at 7:53 PM
Sorry for not replying earlier, I didn't ever see that you had responded, thank you, that fixed it!

Adam