XAML-bound single-pole MVVM object

NOTES

I'm a newbie, sometimes I get hung up on simple and / or stupid thoughts, this is one of them.

I get a general idea about data binding, I went through some of the training programs on the network and earned within a few hours through a lot and a lot of text, which only confused me a little.

PROBLEM

I am working on a Windows Phone 8 C # / XAML.NET 4.5 Application .

Using the web service provided to me in several ways, I upload the data that I need to view (sometimes in different combinations), and I need to store most of them for the duration of the application launch.

  • For this purpose, I created ViewModel + several models and structured them as follows:

    MainViewModel
    --------------
    |
    + several properties (Username, Password, etc...)
    |
    + Commands (loadData1, loadData2, flush, ...  - implementations of ICommand)
    |
    + ------ PersonalInfoModel
    |        -----------------
    |        + several properties (name, surname, phonenumber, etc...)
    |
    |             
    + ------ DataGroup1Model
    |        ---------------
    |        +several properties
    |        +ObservableCollection<Item1> (roughly 0 - 50 items)
    |        +ObservableCollection<Item2> (roughly 0 - 5 items)
    |        +ObservableCollection<string> (roughly 0 - 5 items)
    |        
    |                  Item1                         Item2
    |                  -----                         -----
    |                  +several properties           +several other properties
    |                  
    |
    + ------ DataGroup2Model (similar to previous)
    ...et cetera...
    

    ViewModel ( ), , , ( / ).


  • MainViewModel App.xaml.cs :

    private static MainViewModel viewModel = null;
    public static MainViewModel ViewModel
    {
        get
        {
            if (viewModel == null)
            {
                viewModel = new MainViewModel();
            }
            return viewModel;
        }
    }
    

    . , MVVM / -, ViewModel , . , .


  • viewModel, /datacontext XAML

  • ?

  • itemSource listBox/longListSelector Text , , PersonalInfoModel MainViewModel, ?

P.S.: , . , , - , , " , ".

+2
1

, , : View ViewModel? , , MVVM MVVM.

: ViewModel, , View DataContext. XAML, Microsoft DataContext , WP:

codebehind :

DataContext = App.MainViewModel;

, , -

WPF, WP8, .

, , :

<TextBlock Text="{Binding PersonalInfoModel.Name}" />
+4

All Articles