S
S
Smilley2016-04-12 16:21:06
Programming
Smilley, 2016-04-12 16:21:06

How to properly initialize a variable?

Good afternoon. Can you please tell me how to correctly initialize a variable when using MVVM? The problem is:
-I have a GridView in one part of the window that is bound to a collection of objects. The SelectedItem property is also bound

SelectedItem="{Binding SelectedEntry, Mode=TwoWay}"

private Model.EmailEntry _selectedEntry;
public Model.EmailEntry SelectedEntry
        {
            get { return _selectedEntry; }
            set { _selectedEntry = value; OnPropertyChanged("SelectedEntry");}
        }

-There is a window with detailed data (with the ability to edit) from the SelectedEntry object, the binding goes to the Model.EmailEntry properties
- There is a "Save" button, which is supposed to update the data for the Model.EmailEntry, but when I try to get the values ​​from the SelectedEntry.Property , it says that the SelectedEntry is not initialized, although the data is pulled into the detailed form.
On this topic, I also wanted to ask where it is correct to store the procedure for updating values. Should it be in the Model by the Model.EmailEntry.Update() method or should the method be in the ViewModel? Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question