Xamarin.Forms MVVM with XAML [6 of 11]

Play Xamarin.Forms MVVM with XAML [6 of 11]

The Discussion

  • User profile image
    Mario Vrhoci

    Hi!
    How I can create MVVM XAMLUI.ViewModels, MainPageViewModel.cs?
    It is not par of this video tutorial.
    Thank You!
    Best Regards,
    Mario

  • User profile image
    MattSoucoup
    @Mario Vrhoci: Hi Mario - if you go to the GitHub repo there will be a code example you can download. Essentially you'll need to create a class and make sure it implements the INotifyProperty changed interface.
  • User profile image
    Citaro

    May I know what is under the "public MainPageViewModel()"? It wasn't shown in this video or video 5 of 11 either. Thanks

  • User profile image
    Citaro

    Sorry, I mean do we create this MainPageViewModel.cs as a new class under "XAMLUI"?

  • User profile image
    Greg

    It probably is not a good idea to hide code during a tutorial.Line:10 What is the code hidden under
    public MainPageViewModel()...

  • User profile image
    Amin

    Thank you for the short and sweet tutorials. I love what you are doing and what you have done with Xamarin. But fellows, we need better tooling since, based on this video, there's just too much typing and details to remember for doing something so simple. Can you make it like WinForm where you drag and drop a control and double click on it for the code-behind event handling, write your code, and move on to better things in life?

  • User profile image
    Kyle

    Hi I am following your tutorial on Xamarin and I've encountered a problem when 'clicking' the save button I'm getting a null reference exception. Any help would be appreciated. Thanks Kyle.

  • User profile image
    Carlos

    Hi, thanks for the tutorial, helped a lot for starts. The Save command was declared as "SaveCommand" but in xaml you binded "SaveNoteCommand" (and same for the Erase command) so should the commands function? ;)


    Got the same problem as Kyle, null reference exception. Then i used:

    ObservableCollection<string> AllNotes = new ObservableCollection<string>();

    instead of:

    public ObservableCollection<string> AllNotes { get; set; }

    But the data does not appear in the label with the {Binding .}

  • User profile image
    IVSoftware
    Carlos, kudos for catching the missing initialization for AllNotes, but try doing it like so:

    public ObservableCollection AllNotes { get; set; } = new ObservableCollection();

    I believe the visibility issue in your code might be the result of omitting the 'public' keyword. I notice you also changed the AllNotes property into a field instead. Might be better to keep it as a property {get; set;} but then apply your initializer to that as shown.

    Happy coding!
  • User profile image
    meir

    hi
    I created the MainPageViewModel.cs when i try to add xlmns:local statement I get an error saying "the property local not found in type "ContentPage"??

    Looking forward to your help in this

    Regards

    Meir

  • User profile image
    meir

    Please ignore my above comment .. Silly Typo error on my side!!!

    Meir

  • User profile image
    Carlos

    IVSoftware, thank you for your help. ASAP i will try it.

  • User profile image
    Bo B

    This is such a typical developer tutorial. The first videos in the series start out slow and easy - then all of the sudden the pre-requisites for understanding what's going on explodes.

    "This is where we left off" - Great, I need to follow along every step because I'm a newbie.
    "I have just created this (while not recording)" - well great, that's not really where we left off then is it? But I guess I'll figure out.

    Then proceeds to ramp up programming level without explaining it at all to level 'seasoned C# programmer'.

  • User profile image
    MattSoucoup
    @Bo B: thanks for the comment.

    I realize it can be difficult to pick up on everything in such short videos. To help out there is an accompanying GitHub repo. This folder in particular deals with this episode: https://github.com/codemillmatt/xamarin-101/tree/master/xaml-mvvm

    Hopefully this helps out. Please feel free to reach out should you have any questions.

    Matt
  • User profile image
    JT Anderson

    Grrr...

    Trying to follow along with the Xamarin 101 tutorial. This is now the 14th tutorial project I have created trying to learn and understand how to convert my antique Visual FoxPro skills to the "modern" world.

    Every single time, I invest hours only to slam into unexplained or incompatible code, or in this case HIDDEN code???

    Really???

    Microsoft should be better than this

Add Your 2 Cents